×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    8

    Assembling a picture from several blocks

    Hello,

    I have a problem with Nokia S40 (all models I tried - C1, C2, 6603 etc.)
    In my Java application, I need to assemble a picture from several rectangular blocks that are jpeg-compressed. When I decode blocks and then combine them into bigger image, the resulting blocks have slightly different brightness - so I can see it on the resulting image. The code fragment is:

    Fragment decoding:

    Code:
     Image blockImage = Image.createImage(blockSize.width, blockSize.height);
     Graphics blockGraphics = blockImage.getGraphics();
     Image fragmentImg = Image.createImage(fragment.getData(), fragment.getBegin(), fragment.getLength());
     blockGraphics.drawImage(fragmentImg, fragment.getBase().x, fragment.getBase().y, 0);
    Putting the fragment onto resulting image:

    Code:
     fullImage = Image.createImage(width, height);
     bufferGraphics = fullImage.getGraphics();
     bufferGraphics.drawImage(blockImage, localBlockBase.x, localBlockBase.y, 0);
    Everything works OK on WTK emulators as well as on my Sony ErricssonK750 - all fragments have the same brightness and tone and there are no visible bounds between fragments.

    Could anybody help me - how to work out my problem?

    Thank you.

  2. #2
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Assembling a picture from several blocks

    Hi whoknowswhocares,

    Could this be an issue of the color depth of your jpeg image. The number of bits per pixel the images will have is chosen by the device to match it's display hardware. The Series 40 devices you mentioned has a color depth of 16 bit. The K750 seems to have color depth of 18 bit. So if your image color depth is higher than 16 bit then convert it to a 16 bit image to see if that makes the difference seen on S40 devices.

    -tiviinik

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    8

    Re: Assembling a picture from several blocks

    Thanks for answer, but i don't think that problem in colour depth, cause even monotonous image in different blocks have different brightness
    for example:
    image - RGB:255,255,131, server send it in different blocks, after recieving them client make one block RGB:255,255,79, the other is RGB:255,255,105
    What's wrong with this?

  4. #4
    Registered User
    Join Date
    Apr 2012
    Posts
    8

    Re: Assembling a picture from several blocks

    Hello,

    I believe that the problem is not in color depth. I made an example with a somple picture like

    000000111111
    000000111111
    111111000000
    111111000000

    where
    0 = color in RGB: 0,128,0
    1 = color in RGB: 128,0,0

    I got on Nokia emulators when decoding central fragment:

    000111
    000111
    111000
    111000

    where 0 = RGB:0,226,0

    At the same time, when decoding fragment

    000
    000
    111
    111


    got 0 = RGB:0,161,0

    Such a difference in color is hardly caused by color depth.

    The picture is created from input stream by method Image.createImage(Data,Begin,Length),
    Method Image.createRGBImage() is not applicable for big images as well as "manual" colors correction using Graphics.getRGB() and Graphics.drawRGB() methods.

    By my experiments I found out that Nokia emulators process as follows:
    For each base color there are 16 levels each of them has its own color value,
    If the concrete pixel falls into one of these level, its color gets one of those 16 possible values (the same value for the whole area), so for each base color 16 different levels are possible, so for 3 colors and alpha channel 16 bits is enough.

    It looks like the problem relates either to decoding method or to image creation in Nokia phones.

    Are there any ways to work it out/workaround/...? I would be grateful for any ideas...

  5. #5
    Registered User
    Join Date
    Apr 2012
    Posts
    8

    Re: Assembling a picture from several blocks

    Here is a simple example, but in Nokia devices i recieved different images if "middleBlock.jpg" and "leftBlock.jpg" have a structure that i mentioned before

    Code:
      
                Form form = new Form("form");
                Display display = Display.getDisplay(this):                                   
                form.addCommand(getExitCommand());
                form.setCommandListener(this);                                  
                try {
                    InputStream is = getClass().getResourceAsStream("/middleBlock.jpg");
                    Image img1 = Image.createImage(is);
                    form.append(img1);
                    is = getClass().getResourceAsStream("/leftBlock.jpg");
                    Image img2 = Image.createImage(is);
                    form.append(img2);
                    is.close();
                }catch (IOException e) { }
                display.setCurrent(form);

  6. #6
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Assembling a picture from several blocks

    Hi whoknowswhocares,

    I tested the following code snippet with a png and jpg image with the color code 255,255,131.

    Code:
    public void startApp() {
    		Display display = Display.getDisplay(this);     
    
    		Form form = new Form("form");
    
    		try {
    			InputStream is = getClass().getResourceAsStream("/rect.jpg");
    			Image img1 = Image.createImage(is);
    			form.append(img1);
    			form.append(getRGBofOnePixel(img1,0));
    			form.append("\n\n");
    			is = getClass().getResourceAsStream("/rect.png");
    			Image img2 = Image.createImage(is);
    			form.append(img2);
    			form.append(getRGBofOnePixel(img2,0));
    			is.close();
    		}catch (IOException e) { }
    
    		display.setCurrent(form);
    
    
    
    	}
    
    	public String getRGBofOnePixel(Image image,int pixelNumber)
    	{
    		int t[] = new int[image.getWidth()*image.getHeight()];
    
    		image.getRGB(t, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
    
    		return "RGB: "+((t[pixelNumber]& 0x00FF0000)>>16)+","+((t[pixelNumber]& 0x0000FF00)>>8)+","+((t[pixelNumber]& 0x0000FF));
    	}
    The result where:
    device with 18bit
    jpg = 255,255,113
    png = 255,255,132

    device with 24bit
    jpg = 255,255,131
    png = 255,255,131

    So it seems that there are atleast some difference with jpg and png images. Have you tested your code with a 24 bit devices or with png images. Are there result the same?

    The color difference in your post #4 is so big that it can't be explained with color depth. I'll have to investigate a bit more on this issue and get back to you.

    -tiviinik

  7. #7
    Registered User
    Join Date
    Apr 2012
    Posts
    8

    Re: Assembling a picture from several blocks

    still waiting for some usefull answers....

  8. #8
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: Assembling a picture from several blocks

    Apologies for a delayed answer and sorry for disappointing you again. It seems that this is an old issue that still exists. So my suggestion for a workaround would be to use PNG images.

    http://www.developer.nokia.com/Commu..._(Known_Issue)
    http://www.developer.nokia.com/Commu...-on-S40-3rd-ed

Similar Threads

  1. CameraMMS - Captured picture doesn't correspond to picture in view finder on E52
    By nikolajkolbe in forum [Archived] Qt Mobility Project
    Replies: 8
    Last Post: 2010-11-24, 20:33
  2. J2ME Polish Resource Assembling Problem
    By kamoo in forum Mobile Java General
    Replies: 3
    Last Post: 2009-11-18, 12:53
  3. SMS sending blocks
    By tremix in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-04-24, 06:56
  4. Need to select picture from picture gallery and display it
    By decs75 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2005-07-05, 04:46
  5. Picture Message text/picture ratio Help
    By desmondchang in forum Smart Messaging
    Replies: 1
    Last Post: 2002-10-14, 10:25

Posting Permissions

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