Pixel array

  • Thread starter Anitha Namachivayam via JavaKB.com
  • Start date
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top