×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    7

    is it Possible to Resize a Picture in MIDP1 ?

    i know how can i Resize a picture with MIDP2 ,
    is it Possible to do this with MIDP1 ?


    thanks..

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

    Re: is it Possible to Resize a Picture in MIDP1 ?

    It's possible but not easy. The problem is that MIDP 1.0 doesn't give you any methods to get the pixel data of the picture. So in order to use the method I gave you in the other thread you would have to write your own png decoding/encoding method.

    You can find some code to get you started on that here.

    shmoove

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    7

    Re: is it Possible to Resize a Picture in MIDP1 ?

    I can get the Hexa Nr of a Picture by some Editor and put it in a byte Array
    and


    static byte dukeData[] = {

    (byte)0x89,(byte)0x50,(byte)0x4E,(byte)0x47,(byte)0x0D
    ,...........}

    img = Image.createImage(dukeData, 0, dukeData.length);




    if i have the byteArray, can i use the Hexa Nr for Resizing with MIDP2 code ,which you gave me ?

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

    Re: is it Possible to Resize a Picture in MIDP1 ?

    No because that data is not raw pixel data (which is what you need for the resizing algorithm), it's encoded (usually PNG encoded) data.

    That's why I said you have to write methods to decode (to get the raw pixel data from the encoded data) and encode (so you can convert the resized pixel data into a byte array that you can use with createImage) images.

    You can get the specification for PNG and other formats from Wotsit.

    shmoove

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    2

    Re: is it Possible to Resize a Picture in MIDP1 ?

    It's not necessary to write your own decoding algorythm. You can let the JVM + Nokia UI do it for you by drawing the PNG on an off-screen graphics context and the use GetPixels to get the pixeldata. Here's the code I use in my program(designed for MIDP1.0 12bit color):

    Image temp = Image.createImage("/crosshair.gif");
    Image workSpaceImg = Image.createImage(16,16);
    DirectGraphics workSpace = DirectUtils.getDirectGraphics(workSpaceImg.getGraphics());
    workSpace.drawImage(temp, 0, 0, Graphics.LEFT | Graphics.TOP, 0);
    workSpace.getPixels(image, 0, 16, 0, 0, 16, 16, DirectGraphics.TYPE_USHORT_4444_ARGB);

    What it does: it creates a blank 16x16 image plus an image from the GIF file, gets the graphics context of the blank image, draws the GIF image on that context, and gets the pixels(image is a short[] array)

    Encoding is not possible this way i guess, so for that you have to write some code.
    Last edited by Cheiz; 2006-09-18 at 23:33.

  6. #6
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Berlin, Germany
    Posts
    58

    Re: is it Possible to Resize a Picture in MIDP1 ?

    Probably a bit too late..

    But an obvious solution is to scale a source image vertically first by blitting only the required lines to a temporary image. Then doing the same horizontally.

    I use this approach to have a generic MIDP1 scaling method in a small slideshow engine.

    cheers,

    tfdj

  7. #7
    Registered User
    Join Date
    Oct 2006
    Location
    Recife - PE, Brazil
    Posts
    7

    Re: is it Possible to Resize a Picture in MIDP1 ?

    Creating a Thumbnail Image
    source: http://developers.sun.com/techtopics...icles/picture/

    One seemingly simple thing I wanted to do in this article was talk about how to create a thumbnail image, a smaller version of the image captured from the camera. MIDP 2.0 includes methods for obtaining the raw pixel values of an Image, which would make a true scaling transformation possible. Unfortunately MIDP 1.0 does not provide access to the pixel data.

    The solution I implemented is neither elegant nor strictly correct (in an image-processing sense), but it approximates the behavior I wanted and doesn't involve parsing the PNG format. I create a new (blank) image for the thumbnail. For each pixel of that image, I set the clipping region to encompass that single pixel, and draw the source image at an appropriately scaled location.

    private Image createThumbnail(Image image) {
    int sourceWidth = image.getWidth();
    int sourceHeight = image.getHeight();

    int thumbWidth = 64;
    int thumbHeight = -1;

    if (thumbHeight == -1)
    thumbHeight = thumbWidth * sourceHeight / sourceWidth;

    Image thumb = Image.createImage(thumbWidth, thumbHeight);
    Graphics g = thumb.getGraphics();

    for (int y = 0; y < thumbHeight; y++) {
    for (int x = 0; x < thumbWidth; x++) {
    g.setClip(x, y, 1, 1);
    int dx = x * sourceWidth / thumbWidth;
    int dy = y * sourceHeight / thumbHeight;
    g.drawImage(image, x - dx, y - dy,
    Graphics.LEFT | Graphics.TOP);
    }
    }

    Image immutableThumb = Image.createImage(thumb);

    return immutableThumb;
    }

Similar Threads

  1. resize picture
    By bennet_chen in forum Mobile Java Media (Graphics & Sounds)
    Replies: 12
    Last Post: 2006-11-20, 23:13
  2. Sending Nokia Picture Messages with one SMS?
    By paulmckillop in forum Smart Messaging
    Replies: 8
    Last Post: 2006-11-10, 05:52
  3. picture messages
    By AliNaqvi in forum Smart Messaging
    Replies: 2
    Last Post: 2006-05-10, 12:43
  4. Unable to open Picture message on certain Nokia's
    By ingo.pak in forum Smart Messaging
    Replies: 3
    Last Post: 2004-02-09, 09:51
  5. Picture Message to 3310 ERROR
    By belgiozen in forum Smart Messaging
    Replies: 1
    Last Post: 2002-07-17, 10:57

Posting Permissions

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