×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    75

    Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    HI all,
    I use Images to create sprites, I directly draw them on screen or use in tyled layers.
    All my images are:
    -png
    -72dpi
    -256 colors
    -transparent background
    With all the phones and all the emulators this works fine BUT on a E65 (s60 3rd fp1) some images lose transparency. Not all of them and the ones that lose the transaprent color have some a black and some a white backround instead of a transparent one.

    Please HELP!

  2. #2
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    75

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    Has anyone experienced the same problem with transparent png files on e65 or s60 3rd fp1 phones?

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    only seen something a bit similar when using C++, basically some stuff that worked really nicely in N73 had masks distorded when used in N95/N76, basically my problem was that I scalaed images to different size when loading than what was used in drawing. Scaling to the excat drawing size right after loading them fixed my problem, though not sure if this can be applied to the Java.

    yucca

  4. #4
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    75

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    You mean load the image Image.createImage() and then resize()? I then use the images to create Sprites and I append to layers on screen

    I can't resize just after loading since I have to calculate if I "need" a resize and of course calculare the resize rate.

    Any suggestions from someone who experienced this in Java?

  5. #5
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    75

    Re: Problem with TRANSPARENCY HELPPPP!!!!!

    I got it (almost)
    it's this pice of code...
    Code:
        public Image resizeImage(Image src, int destW, int destH, int mode) {
            try {
                int srcW = src.getWidth();
                int srcH = src.getHeight();
                
                // create pixel arrays
                int[] srcPixels = new int[srcW];
                int[] destPixels = new int[destW * destH]; // array to hold destination pixels
                
                // precalculate src/dest ratios
                int ratioW = (srcW << FP_SHIFT) / destW;
                int ratioH = (srcH << FP_SHIFT) / destH;
                if (mode == FAST_RESAMPLE) {
                    long ini = System.currentTimeMillis();
                    // simple point smapled resizing
                    // loop through the destination pixels, find the matching pixel on the source and use that
                    int p =0;
                    for (int destY = 0; destY < destH; ++destY) {
                        int srcY = (destY * ratioH) >> FP_SHIFT; // calculate beginning of sample
                        // int srcY = (destY * srcH) / destH;
                        src.getRGB(srcPixels,0,srcW,0,srcY,srcW,1);
                        for (int destX = 0; destX < destW; ++destX) {
                            int srcX = (destX * ratioW) >> FP_SHIFT; // calculate beginning of sample
                            // int srcX = (destX * srcW) / destW;
                            destPixels[p++] = srcPixels[srcX];
                        }
                    }
                    //System.out.println("fast: "+(System.currentTimeMillis()-ini)+"ms");
                } else {
                    long ini = System.currentTimeMillis();
                    byte[] tmpA = new byte[destW * srcH];
                    byte[] tmpR = new byte[tmpA.length]; // temporary buffer for the horizontal resampling step
                    byte[] tmpG = new byte[tmpA.length];
                    byte[] tmpB = new byte[tmpA.length];
                    
                    // variables to perform additive blending
                    int argb; // color extracted from source
                    int a, r, g, b; // separate channels of the color
                    int count; // number of pixels sampled for calculating the average
                    
                    // the resampling will be separated into 2 steps for simplicity
                    // the first step will keep the same height and just stretch the picture horizontally
                    // the second step will take the intermediate result and stretch it vertically
                    
                    // horizontal resampling
                    int p =0;
                    for (int y = 0; y < srcH; ++y) {
                        src.getRGB(srcPixels,0,srcW, 0,y, srcW,1);
                        for (int x = 0; x < destW; ++x) {
                            int srcX = (x * ratioW) >> FP_SHIFT; // calculate beginning of sample
                            int srcX2 = ((x + 1) * ratioW) >> FP_SHIFT; // calculate end of sample
                            if (srcX2 >= srcW) srcX2 = srcW-1;
                            
                            count = srcX2 - srcX + 1;
                            // now loop from srcX to srcX2 and add up the values for each channel
                            for (a = r = b = g = 0; srcX <= srcX2; srcX++) {
                                argb = srcPixels[srcX];
                                a += (argb >> 24) & 0xFF;
                                r += (argb >> 16) & 0xFF;
                                g += (argb >> 8)  & 0xFF;
                                b +=  argb        & 0xFF;
                            }
                            // average out the channel values
                            tmpA[p] = (byte)(a/count);
                            tmpR[p] = (byte)(r/count);
                            tmpG[p] = (byte)(g/count);
                            tmpB[p] = (byte)(b/count);
                            p++;
                        }
                    }
                    
                    // vertical resampling of the temporary buffer (which has been horizontally resampled)
                    for (int x = 0; x < destW; ++x)
                        for (int y = 0, xx=x; y < destH; y++, xx += destW) {
                        int srcY = (y * ratioH) >> FP_SHIFT; // calculate beginning of sample
                        int srcY2 = ((y + 1) * ratioH) >> FP_SHIFT; // calculate end of sample
                        if (srcY2 >= srcH) srcY2 = srcH-1;
                        
                        count = srcY2 - srcY + 1;
                        // now loop from srcY to srcY2 and add up the values for each channel
                        p = x + srcY * destW;
                        for (a = r = b = g = 0; srcY <= srcY2; srcY++, p += destW) {
                            a += tmpA[p] & 0xFF; // ALPHA
                            r += tmpR[p] & 0xFF; // red channel
                            g += tmpG[p] & 0xFF; // green channel
                            b += tmpB[p] & 0xFF; // blue channel
                        }
                        // recreate color from the averaged channels and place it into the destination buffer
                        destPixels[xx] = ((a/count) << 24 | (r/count) << 16) | ((g/count) << 8) | (b/count);
                        }
                    //System.out.println("slow: "+(System.currentTimeMillis()-ini)+"ms");
                }
                srcPixels = null;
                // return a new image created from the destination pixel buffer
                return Image.createRGBImage(destPixels,destW,destH,true);
                // note that if you put back alpha support, have to change false above to true or the alpha channel will be ignored
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
    It's the resizing. It works fine everywhere butr on a real s60 3rd fp1 (nokia e65) it loses transparency!!!!


    Why?????????????????

  6. #6
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Problem with TRANSPARENCY HELPPPP!!!!!

    Hi sandro,

    I do not have answer to your question, but I want a clarification for one thing. You mentioned E65, which is a S60 3rd Edition phone even though you talk about the S60 3rd Edition FP1. Did you mean N95 (which is a S60 3rd Edition FP1 phone) or E65?
    This would help in troubleshooting.

    Hartti

  7. #7
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    75

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    Hi,
    are you saying that I should try to deply it with the correct SDK? Anyway I don't understand why it works perfectly with all the phones and all the emulators (even s60 3rd fp1), But on a real E65 it doesn't show transparency of resized images

  8. #8
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    No, I was just correcting that the E65 is not a S60 3rd Edition FP1 phone. But it might make sense to test with the correct emulator also.
    However you do not list the devices which are successful in running this application. Can you tell what devices you have tested this on?

    Hartti

  9. #9
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    75

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    Well, well
    The emulator shows my splash screen and then blank. It has a @##@!?! behaviour whenever I paint a canvas with any kind of image on it. So at this point I'll have to say that S60 3rd ed Symbian phones won't be able to run my software. And now I wonder why there are almost no games for my e65 around.
    I am so disappointed! Why do you think is this happening? I am sure there is nothing wrong with my code. Or at least splash and intro are so simple and work fine everywhere else.

    Alex

  10. #10
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    Unhappy Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    For googlers and for completeness of the thread.

    Regarding this issue, I know some buggy E61 (can't tell the OS version). Moreover, the Nokia online simulator features the same bug, so I guess it's note one single phone that features this "transparency lost" bug.

    In my applications, calls to .getRGB() just *discards* the alpha channel and converts the image to a non-transparent one. I have to color-code transparent pixels (eg. with slime green), and set them back as transparent afterwards by hand; this is quite ugly and slow but I found no other way round
    It's really bad that this bug was not detected by the QA at Nokia imho!

    Jim

  11. #11
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Smile Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    Hi guys, i have a Nokia N73, i've been playing with transparent PNG images.
    It took some time to get it right, but i have sorted it!.
    Using Photoshop, you need to create a new file, which needs to be 600pixels x 600 pixels with a resolution of 600dpi, colour mode RGB and background set as transparent.
    Once your image is created, shadows, texture effects, etc, you need to then select File/Save As/ use the drop down menu to select saving as .PNG, send it to your phone, job done!
    I've had no problems with random non transparencies that you talk of.
    regards
    Markkyboy

  12. #12
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    I guess the problem is really located around some anomality of the E65.
    Have same issues as the others here. For the simualator, everything works fine,
    deploying the software on the mobile phone causes losing transparency for the sprites.

    (allthough the normal Images work fine, even with transparency)

    Has someone found a soultion yet?

    regards

  13. #13
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Problem with S60 3rd FP1 device! Image "randomly" not TRANSPARENT

    Are you drawing the images with their correct size ?
    FP1 devices have had good amoutn of problems when drawing transparent images with other size than their current size. Maybe it is same problem, even when E65 is not FP1 device. so try re-sizing the image & mask to the same size as their drawing area is, and see whether the problem goes away.

Similar Threads

  1. Extra E90 screen size in the S60 3rd edition FP1 emulator
    By svdwal in forum Symbian Tools & SDKs
    Replies: 34
    Last Post: 2009-05-12, 08:55
  2. Replies: 2
    Last Post: 2007-03-13, 13:27
  3. Hotkey support in S60 3rd ed FP1
    By svdwal in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-02-12, 12:09
  4. Replies: 3
    Last Post: 2004-04-20, 07:40

Posting Permissions

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