×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    18

    Angry How can i g.CreatImage(byte [],....) with a byteArray

    i try to write a code and i can not find how can i creat an image with bytearray , i do not want to use apng.


    or is there an ImageCanverter for midp1 and midp2


    you will help me so much
    tank you.




    mehi4you@yahoo.de

    byby

  2. #2
    Registered User
    Join Date
    Feb 2004
    Posts
    9
    There 're several ways to solve problem:

    1) First one is for MIDP 2 devices.
    Image myImage = Image.createRGBImage(byte[] data, int width, int height, boolean processAlpha);

    Each element of data is pixel in 0xAARRGGBB format.

    2) Second way.
    To my opinion it is slow to initialize and ugly by nature .

    Code:
    int[] data = {pixels array of  width*height length};
    Image myImage = Image.createImage(width, height);
    Graphics g = myImage.getGraphics();
    for(int y=0; y<height; y++){
          for(int x=0; x<width; x++){
                g.setColor(data[y*width+x]);
                g.fillRect(x,y, 1,1);
          }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×