Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Gdip_FilterColor(unsigned char * Bitmap, int w, int h, int Stride, unsigned int Color, unsigned int ReplaceColor, int v)
- {
- unsigned int p, A1, R1, G1, B1, A2, R2, G2, B2, tA, tR, tG, tB;
- A1 = (Color & 0xff000000) >> 24;
- R1 = (Color & 0x00ff0000) >> 16;
- G1 = (Color & 0x0000ff00) >> 8;
- B1 = Color & 0x000000ff;
- A2 = (ReplaceColor & 0xff000000) >> 24;
- R2 = (ReplaceColor & 0x00ff0000) >> 16;
- G2 = (ReplaceColor & 0x0000ff00) >> 8;
- B2 = ReplaceColor & 0x000000ff;
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- p = (4*x)+(y*Stride);
- tA = Bitmap[3+p];
- tR = Bitmap[2+p];
- tG = Bitmap[1+p];
- tB = Bitmap[p];
- if ((tA <= A1+v && tA >= A1-v) && (tR <= R1+v && tR >= R1-v) && (tG <= G1+v && tG >= G1-v) && (tB <= B1+v && tB >= B1-v))
- {
- Bitmap[3+p] = A2;
- Bitmap[2+p] = R2;
- Bitmap[1+p] = G2;
- Bitmap[p] = B2;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement