Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*by xerpi*/
- void pngx_RGBAto4X4RGBA(uint8_t *srcBuff, uint8_t *dstBuff, uint32_t buffWidth, uint32_t buffHeight)
- {
- //RGBA format: 0xRRGGBBAA
- /*
- AARRAARR AARRAARR AARRAARR AARRAARR
- AARRAARR AARRAARR AARRAARR AARRAARR
- GGBBGGBB GGBBGGBB GGBBGGBB GGBBGGBB
- GGBBGGBB GGBBGGBB GGBBGGBB GGBBGGBB
- */
- uint8_t *src = srcBuff;
- uint8_t *dst = dstBuff;
- uint32_t y, x, i, j;
- uint8_t *block;
- for(y = 0; y < buffHeight; y+=4)
- {
- for(x = 0; x < buffWidth; x+=4)
- {
- for(i = 0; i < 4; i++)
- {
- for(j = 0; j < 4; j++)
- {
- block = src + ((x + j) + (y + i) * buffWidth) * 4;
- *(dst ) = *(block + 3); //Alpha
- *(dst + 32) = *(block + 1); //Green
- dst++;
- *(dst ) = *(block); //Red
- *(dst + 32) = *(block + 2); //Blue
- dst++;
- }
- }
- dst+=32;
- }
- }
- /*for(y = 0; y < buffHeight; y+=4)
- {
- for(x = 0; x < buffWidth; x+=4)
- {
- for(i = 0; i < 4; i++)
- {
- for(j = 0; j < 4; j++)
- {
- block = *(uint32_t *)(src + ((x + j) + ((y + i) * buffWidth)) * 4);
- *(dst++) = (block) & 0xFF;
- *(dst++) = (block>>24) & 0xFF;
- }
- }
- for(i = 0; i < 4; i++)
- {
- for(j = 0; j < 4; j++)
- {
- block = *(uint32_t *)(src + ((x + j) + ((y + i) * buffWidth)) * 4);
- *(dst++) = (block>>16) & 0xFF;
- *(dst++) = (block>>8) & 0xFF;
- }
- }
- }
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement