1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
int[] rgb = rgbData;
int size = width * height;
int argb, a, r, g, b;
// redimension de l'image à la taille width, height (fonction que j'ai faite)
Image cache =redimImage(Image.createImage(URL_CACHE), width, height);
cache.getRGB(rgbData, 0, width, 0, 0, width, height);
for(int j=0; j<size;j++){
argb = rgbData[j];
a = ((argb & 0xff000000) >> 24); // alpha channel
r = ((argb & 0x00ff0000) >> 16); // red channel
g = ((argb & 0x0000ff00) >> 8); // green channel
b = (argb & 0x000000ff); // blue channel
a=a-8;
// si la transparence min est atteinte (a compris entre 255 et 0)
if(a<0) a=0;
// on réassemble
rgbData[j] = ((a << 24) | (r << 16) | (g << 8) | b);
}
Image img_temp = Image.createRGBImage(rgbData,width,height,true); |
Partager