×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    1

    Unhappy Transparent background for image using S60 emulator

    Hi all,

    I am trying to display a transparent bg png image on the s60 emulator screen. It works if i just creating the raw image and display it. However, i need to resize the image, so if i resize the raw image and display it on screen, i will get a white background where it should be transparent..

    So far i have tried a few ways to solve the problem.
    <code>
    //create a mutable image
    Image img = Image.createImage(width,height);
    Graphics g = img.getGraphics();

    //set some color that you know you aren`t going to use
    g.setColor(0x123456);
    g.fillRect(0,0,width,height);

    //this is where you draw the things that you want into g
    /* remember that if you are drawing an image into this graphics, it must have
    * the same color that you selected before(ie 0x123456 ) as a background
    *color in order to become transparent later
    */

    //convert that image into a bytearray
    byte[] byteArray;
    img.getRGB(byteArray,0,img.getWidth(),0,0,img.getWidth(),img.getHeight());
    //replace the color that you had put before for a transparent pixel
    for(int i=0;i<byteArray.length;i++){
    if(byteArray[i]==0x123456){
    byteArray[i]=0x00000000;
    }
    }

    //and then create the image with a transparent background
    img=Image.createRGBImage(byteArray,witdh,Height,true);

    >
    </code>

    But it didnt work...the bg color will jus remain as the 1 i set earlier on..

    Any solution to my problem??

  2. #2
    Registered User
    Join Date
    Jan 2007
    Posts
    10

    Re: Transparent background for image using S60 emulator

    in API doc:

    The returned values are not guaranteed to be identical to values from the original source
    in our example returned value in array, are 0x113355

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    Re: Transparent background for image using S60 emulator

    I have a function that does this ... quite simple.


    public Image filterImage(Image image, int transparentColor) {
    int tempPixel;
    int bitMask = 0x00FFFFFF;
    int blankPixel = 0x00000000;
    int colorMask = transparentColor & bitMask;

    int[] imageData = new int[image.getWidth() * image.getHeight()];
    image.getRGB(imageData,0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());

    for(int k=0; k < imageData.length; k++) {
    tempPixel = imageData[k] & bitMask;
    if(tempPixel == colorMask) {
    imageData[k] = blankPixel;
    }
    }

    return Image.createRGB(imageData, image.getWidth(), image.getHeight(), true);
    }

Similar Threads

  1. LBS Application Testing with S60 Emulator
    By kakadu2 in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2008-10-29, 19:46
  2. No video playback support by Nokia S60 Emulator?
    By Bastholomeus in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2007-08-17, 10:13
  3. sync4j sync with the S60 emulator
    By vtulai in forum OMA DM/DS/CP
    Replies: 4
    Last Post: 2007-05-11, 06:12
  4. 'Running in background' 6310 emulator.
    By martinchisnall in forum Mobile Java General
    Replies: 0
    Last Post: 2004-02-11, 20:54
  5. S60 emulator problem
    By petokala in forum Bluetooth Technology
    Replies: 5
    Last Post: 2002-12-20, 13:21

Posting Permissions

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