I got it (almost)
it's this pice of code...
Code:
public Image resizeImage(Image src, int destW, int destH, int mode) {
try {
int srcW = src.getWidth();
int srcH = src.getHeight();
// create pixel arrays
int[] srcPixels = new int[srcW];
int[] destPixels = new int[destW * destH]; // array to hold destination pixels
// precalculate src/dest ratios
int ratioW = (srcW << FP_SHIFT) / destW;
int ratioH = (srcH << FP_SHIFT) / destH;
if (mode == FAST_RESAMPLE) {
long ini = System.currentTimeMillis();
// simple point smapled resizing
// loop through the destination pixels, find the matching pixel on the source and use that
int p =0;
for (int destY = 0; destY < destH; ++destY) {
int srcY = (destY * ratioH) >> FP_SHIFT; // calculate beginning of sample
// int srcY = (destY * srcH) / destH;
src.getRGB(srcPixels,0,srcW,0,srcY,srcW,1);
for (int destX = 0; destX < destW; ++destX) {
int srcX = (destX * ratioW) >> FP_SHIFT; // calculate beginning of sample
// int srcX = (destX * srcW) / destW;
destPixels[p++] = srcPixels[srcX];
}
}
//System.out.println("fast: "+(System.currentTimeMillis()-ini)+"ms");
} else {
long ini = System.currentTimeMillis();
byte[] tmpA = new byte[destW * srcH];
byte[] tmpR = new byte[tmpA.length]; // temporary buffer for the horizontal resampling step
byte[] tmpG = new byte[tmpA.length];
byte[] tmpB = new byte[tmpA.length];
// variables to perform additive blending
int argb; // color extracted from source
int a, r, g, b; // separate channels of the color
int count; // number of pixels sampled for calculating the average
// the resampling will be separated into 2 steps for simplicity
// the first step will keep the same height and just stretch the picture horizontally
// the second step will take the intermediate result and stretch it vertically
// horizontal resampling
int p =0;
for (int y = 0; y < srcH; ++y) {
src.getRGB(srcPixels,0,srcW, 0,y, srcW,1);
for (int x = 0; x < destW; ++x) {
int srcX = (x * ratioW) >> FP_SHIFT; // calculate beginning of sample
int srcX2 = ((x + 1) * ratioW) >> FP_SHIFT; // calculate end of sample
if (srcX2 >= srcW) srcX2 = srcW-1;
count = srcX2 - srcX + 1;
// now loop from srcX to srcX2 and add up the values for each channel
for (a = r = b = g = 0; srcX <= srcX2; srcX++) {
argb = srcPixels[srcX];
a += (argb >> 24) & 0xFF;
r += (argb >> 16) & 0xFF;
g += (argb >> 8) & 0xFF;
b += argb & 0xFF;
}
// average out the channel values
tmpA[p] = (byte)(a/count);
tmpR[p] = (byte)(r/count);
tmpG[p] = (byte)(g/count);
tmpB[p] = (byte)(b/count);
p++;
}
}
// vertical resampling of the temporary buffer (which has been horizontally resampled)
for (int x = 0; x < destW; ++x)
for (int y = 0, xx=x; y < destH; y++, xx += destW) {
int srcY = (y * ratioH) >> FP_SHIFT; // calculate beginning of sample
int srcY2 = ((y + 1) * ratioH) >> FP_SHIFT; // calculate end of sample
if (srcY2 >= srcH) srcY2 = srcH-1;
count = srcY2 - srcY + 1;
// now loop from srcY to srcY2 and add up the values for each channel
p = x + srcY * destW;
for (a = r = b = g = 0; srcY <= srcY2; srcY++, p += destW) {
a += tmpA[p] & 0xFF; // ALPHA
r += tmpR[p] & 0xFF; // red channel
g += tmpG[p] & 0xFF; // green channel
b += tmpB[p] & 0xFF; // blue channel
}
// recreate color from the averaged channels and place it into the destination buffer
destPixels[xx] = ((a/count) << 24 | (r/count) << 16) | ((g/count) << 8) | (b/count);
}
//System.out.println("slow: "+(System.currentTimeMillis()-ini)+"ms");
}
srcPixels = null;
// return a new image created from the destination pixel buffer
return Image.createRGBImage(destPixels,destW,destH,true);
// note that if you put back alpha support, have to change false above to true or the alpha channel will be ignored
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
It's the resizing. It works fine everywhere butr on a real s60 3rd fp1 (nokia e65) it loses transparency!!!!
Why?????????????????