I have a .PNG image with a transparent background and a drawing in it with a black color, how could I change the "black drawing color" in this image to any color i want programmatically; using rim 4.5 API ? THANKS IN ADVANCE ....
+1
A:
You can parse the image RGBs searching for the black color and replace it with whatever color you desire.
Ali El-sayed Ali
2010-02-14 10:10:09
Thanks Ali .... in next post you will find the implementation.
Ashraf Bashir
2010-02-14 10:14:38
You are welcome, and nice implementation.
Ali El-sayed Ali
2010-02-14 10:48:42
+1
A:
I found the solution, here it is for those who are interested.
Bitmap colorImage(Bitmap image, int color) {
int[] rgbData= new int[image.getWidth() * image.getHeight()];
image.getARGB(rgbData,
0,
image.getWidth(),
0,
0,
image.getWidth(),
image.getHeight());
for (int i = 0; i < rgbData.length; i++) {
int alpha = 0xFF000000 & rgbData[i];
if((rgbData[i] & 0x00FFFFFF) == 0x00000000)
rgbData[i]= alpha | color;
}
image.setARGB(rgbData,
0,
image.getWidth(),
0,
0,
image.getWidth(),
image.getHeight());
return image;
}
Ashraf Bashir
2010-02-14 10:13:48
Yes it will work, but it won't change any colours that are even slightly off-black, meaning any image which is aliased will end up looking rather ugly.
funkybro
2010-02-15 09:12:52
A:
Pavel Alexeev
2010-02-15 14:45:28