A
Anitha Namachivayam via JavaKB.com
Hello,
I want to convert the binary image to array of pixels. I have posted the
code below. some where i did mistake. i could not rectify it... i am not
getting the image... i am getting only white screen... can anyone help me?
LPBITMAPINFOHEADER lpbmih;
JNIEnv *env;
int width = lpbmih->biWidth;
int height = lpbmih->biHeight;
jintArray pixels = env->NewIntArray (width * height);
int *palette = (int *) lpbmih + sizeof(BITMAPINFOHEADER);
int numColors;
if (lpbmih->biClrUsed > 0)
numColors = lpbmih->biClrUsed;
else
numColors = 1 << lpbmih->biBitCount;
unsigned char *bitmap = (unsigned char *) lpbmih + sizeof(BITMAPINFOHEADER)
+ numColors * sizeof(RGBQUAD);
int padBytes = 1;
jboolean isCopy;
jint *pixelsArray = env->GetIntArrayElements (pixels, &isCopy);
int rowBytes = width+padBytes;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
int pixel = bitmap [rowBytes*row+col/8];
pixel = pixel >> (7 - col%8);
pixel = (pixel & 1);
pixel = pixel? 0xFFFFFFFF : 0xFF000000;
pixelsArray [width*(height-row-1)+col] = (jint) pixel;
}
}
if (isCopy == JNI_TRUE)
env->ReleaseIntArrayElements (pixels, pixelsArray, 0);
..................
........
Thanks in advance,
Sri
I want to convert the binary image to array of pixels. I have posted the
code below. some where i did mistake. i could not rectify it... i am not
getting the image... i am getting only white screen... can anyone help me?
LPBITMAPINFOHEADER lpbmih;
JNIEnv *env;
int width = lpbmih->biWidth;
int height = lpbmih->biHeight;
jintArray pixels = env->NewIntArray (width * height);
int *palette = (int *) lpbmih + sizeof(BITMAPINFOHEADER);
int numColors;
if (lpbmih->biClrUsed > 0)
numColors = lpbmih->biClrUsed;
else
numColors = 1 << lpbmih->biBitCount;
unsigned char *bitmap = (unsigned char *) lpbmih + sizeof(BITMAPINFOHEADER)
+ numColors * sizeof(RGBQUAD);
int padBytes = 1;
jboolean isCopy;
jint *pixelsArray = env->GetIntArrayElements (pixels, &isCopy);
int rowBytes = width+padBytes;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
int pixel = bitmap [rowBytes*row+col/8];
pixel = pixel >> (7 - col%8);
pixel = (pixel & 1);
pixel = pixel? 0xFFFFFFFF : 0xFF000000;
pixelsArray [width*(height-row-1)+col] = (jint) pixel;
}
}
if (isCopy == JNI_TRUE)
env->ReleaseIntArrayElements (pixels, pixelsArray, 0);
..................
........
Thanks in advance,
Sri