Pixel array

Discussion in 'Java' started by Anitha Namachivayam via JavaKB.com, Apr 13, 2005.

  1. 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

    --
    Message posted via http://www.javakb.com
    Anitha Namachivayam via JavaKB.com, Apr 13, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sangeeta

    Pixel Width of Char in Web App

    Sangeeta, Aug 14, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,091
    Jerry III
    Aug 15, 2003
  2. D i s h a n

    Pixel array into Image

    D i s h a n, Jan 8, 2007, in forum: Java
    Replies:
    5
    Views:
    1,878
    Knute Johnson
    Jan 9, 2007
  3. Jason B

    Pixel Array => Bitmap File

    Jason B, Feb 27, 2007, in forum: Python
    Replies:
    3
    Views:
    703
    Jason B
    Feb 27, 2007
  4. André Wagner

    Fastest pixel by pixel operation

    André Wagner, Mar 17, 2008, in forum: Java
    Replies:
    12
    Views:
    1,037
    Larry A Barowski
    Mar 19, 2008
  5. jimgardener

    size of pixel data array

    jimgardener, Nov 15, 2010, in forum: Java
    Replies:
    4
    Views:
    662
    John B. Matthews
    Nov 15, 2010
Loading...

Share This Page