You Are Here:

Community: Developer Discussion Boards

#1 Old is it Possible to Resize a Picture in MIDP1 ? - 2006-08-27, 04:42

Join Date: Aug 2006
Posts: 7
mehiii2
Offline
Registered User
i know how can i Resize a picture with MIDP2 ,
is it Possible to do this with MIDP1 ?


thanks..
Reply With Quote

#2 Old Re: is it Possible to Resize a Picture in MIDP1 ? - 2006-08-27, 11:29

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
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
Reply With Quote

#3 Old Re: is it Possible to Resize a Picture in MIDP1 ? - 2006-08-27, 16:55

Join Date: Aug 2006
Posts: 7
mehiii2
Offline
Registered User
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 ?
Reply With Quote

#4 Old Re: is it Possible to Resize a Picture in MIDP1 ? - 2006-08-27, 17:23

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
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
Reply With Quote

#5 Old Re: is it Possible to Resize a Picture in MIDP1 ? - 2006-09-19, 00:25

Join Date: Sep 2006
Posts: 2
Cheiz
Offline
Registered User
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-19 at 00:33.
Reply With Quote

#6 Old Re: is it Possible to Resize a Picture in MIDP1 ? - 2006-09-23, 15:30

Join Date: Apr 2003
Posts: 58
Location: Berlin, Germany
The.French.DJ
Offline
Regular Contributor
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
Reply With Quote

#7 Old Re: is it Possible to Resize a Picture in MIDP1 ? - 2006-10-05, 15:59

Join Date: Oct 2006
Posts: 7
Location: Recife - PE, Brazil
Rafoso
Offline
Registered User
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;
}
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
resize picture bennet_chen Mobile Java Media (Graphics & Sounds) 12 2006-11-21 00:13
Sending Nokia Picture Messages with one SMS? paulmckillop Smart Messaging 8 2006-11-10 06:52
picture messages AliNaqvi Smart Messaging 2 2006-05-10 13:43
Unable to open Picture message on certain Nokia's ingo.pak Smart Messaging 3 2004-02-09 10:51
Picture Message to 3310 ERROR belgiozen Smart Messaging 1 2002-07-17 11:57

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d127641X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZgamesQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ