×

Discussion Board

Results 1 to 3 of 3

Thread: Image Problem

  1. #1
    Regular Contributor
    Join Date
    Oct 2005
    Location
    Cairo,Egypt
    Posts
    72

    Red face Image Problem

    i want to modify image and save it...?

    1- Modifing
    Modifing image mean get graphics instance from this image and draw over it
    trying to do that i face immutable problem and i solve it by using nokia UI GraphicsUtil.CreateImage which return mutable image
    2- Sending this image by WMA 2.0 MMS
    Sending Means converting to byte array i done that by
    public static byte[] getByteArray(Image image){

    // Allocate new memory for the int-array and fill the array in the getRGB method.
    int[]raw = new int[image.getWidth() * image.getHeight()];
    image.getRGB(raw, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());

    byte[]rawByte = new byte[image.getWidth() * image.getHeight() * 4];// ARGB
    int a, r, g, b;
    int n = 0;

    // loop through the int-array and get the 4 bytes of each value to the byte-array.
    // since java isn't supporting unsigned bytes we need to store the ARGB values from -128 to 127
    // where -128 = 128, -127 = 129 and -1 = 255
    for(int i=0; i<raw.length; i++){

    // Right-shift the values to fit in a byte.
    int ARGB = raw[i];
    a = (ARGB & 0xFF000000) >> 24;
    r = (ARGB & 0xFF0000) >> 16;
    g = (ARGB & 0xFF00) >> 8;
    b = (ARGB & 0xFF);

    rawByte[n] = (byte)b;
    rawByte[n+1] = (byte)g;
    rawByte[n+2] = (byte)r;
    rawByte[n+3] = (byte)a;
    n+=4;
    }

    raw=null;
    return rawByte;
    }

    this is not my function i found it over the internt to convert image to byte array
    but trying to send this image give me SizeExceedException and tell me that maximum size is 30781 and when i find that the length of the my image byte array is over 100000 how can be sent....? .. First Question
    3- Saving it using FIleConnection API
    after get the bytearray i create file named like example.png and write to it the byte array of the image but the file can't be open using the phone gallary or the windows image viewr so the byte array may be wrong .....so how can i save this image or the correct convert to byte array ? Sec Question


    soory for the long letter
    Wael Nabil
    Product Manager
    CITGlobal MOBiDIV
    Egypt.

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    Re: Image Problem

    Click me.

    shmoove

  3. #3
    Regular Contributor
    Join Date
    Oct 2005
    Location
    Cairo,Egypt
    Posts
    72

    Re: Image Problem

    Thanks shmoove
    i will read it and return if there is any question
    thanks again
    Wael Nabil
    Product Manager
    CITGlobal MOBiDIV
    Egypt.

Similar Threads

  1. Problem saving an image using FileConnection
    By pmgf_14 in forum Mobile Java General
    Replies: 7
    Last Post: 2008-08-18, 23:41
  2. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  3. scrolling an image larger than the canvas size problem
    By noobprogrammer in forum Mobile Java General
    Replies: 4
    Last Post: 2006-11-20, 03:20
  4. 7650 Image Uploader strange problem
    By kamlesh_in in forum Symbian
    Replies: 1
    Last Post: 2003-08-25, 15:06

Posting Permissions

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