void CloudIcon::makeAlphaIcon(const Graphics::Surface &icon, float alpha) { _alphaIcon.copyFrom(icon); byte *pixels = (byte *)_alphaIcon.getPixels(); for (int y = 0; y < _alphaIcon.h; y++) { byte *row = pixels + y * _alphaIcon.pitch; for (int x = 0; x < _alphaIcon.w; x++) { uint32 srcColor; if (_alphaIcon.format.bytesPerPixel == 2) srcColor = READ_UINT16(row); else if (_alphaIcon.format.bytesPerPixel == 3) srcColor = READ_UINT24(row); else srcColor = READ_UINT32(row); // Update color's alpha byte r, g, b, a; _alphaIcon.format.colorToARGB(srcColor, a, r, g, b); a = (byte)(a * alpha); uint32 color = _alphaIcon.format.ARGBToColor(a, r, g, b); if (_alphaIcon.format.bytesPerPixel == 2) *((uint16 *)row) = color; else *((uint32 *)row) = color; row += _alphaIcon.format.bytesPerPixel; } } }
int sexp_iterator_get_uint32(struct sexp_iterator *iterator, uint32_t *x) { if (iterator->type == SEXP_ATOM && !iterator->display && iterator->atom_length && iterator->atom[0] < 0x80) { size_t length = iterator->atom_length; const uint8_t *p = iterator->atom; /* Skip leading zeros. */ while(length && !*p) { length--; p++; } switch(length) { case 0: *x = 0; break; case 1: *x = p[0]; break; case 2: *x = READ_UINT16(p); break; case 3: *x = READ_UINT24(p); break; case 4: *x = READ_UINT32(p); break; default: return 0; } return sexp_iterator_next(iterator); } return 0; }