You Are Here:

Community: Developer Discussion Boards

#1 Old Cut an image - 2007-09-18, 23:30

Join Date: Mar 2007
Posts: 85
antonio5982
Offline
Regular Contributor
Hi everybody!
I would like to ask you if I can create a new image from another big image. I don't want to resize the image in a small image but I would like to have a new image which is part of the previous one. So it means that if I have an image bigger 300x300, I want to create a image 200x300, so I will cut the rest..... is it possible to create this image? how?

thanks in advance

antonio
Reply With Quote

#2 Old Re: Cut an image - 2007-09-19, 07:52

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
Yes, you can "cut" the big image and create a smaller one. The standard MIDP 2.0 Image object (http://java.sun.com/javame/reference...dui/Image.html) has a method called getRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height). It also has a method called createRGBImage(int[] rgb, int width, int height, boolean processAlpha), which will allow you to create a new image up on previously extracted RGB data.

So, for your case the code would look like:

int[] rgb_data = new int[200 * 300];

big_image.getRGB(rgb_data, 0, 200, 0, 0, 200, 300);

Image smaller_image = Image.createRGBImage(rgb_data, 200, 300, true);
Reply With Quote

#3 Old Re: Cut an image - 2007-09-19, 10:53

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
If you don't care about transparency then you can also simply use Image.createImage(width, height) and draw the bigger image onto the new empty image. This is MIDP 1.0, so it will ease porting.

shmoove
Reply With Quote

#4 Old Re: Cut an image - 2007-09-19, 13:41

Join Date: Mar 2007
Posts: 85
antonio5982
Offline
Regular Contributor
thank you for your reply!

But I have still some problem to create this image.... I hope that you can help me....I will try to specify the problem:

Image image = Image.createImage(....);
int widht = image.getWidth();
int heght = image.getHeigth();

Now I want to create a new image, which should have the same width, but smaller height. What I mean is that I want to cut off the top of the picture - I dont want to show the first 84 pixels of height.... so it will be the same image but starting from the 85th pixel...

thanks again for your help

antonio
Reply With Quote

#5 Old Re: Cut an image - 2007-09-19, 16:45

Join Date: Jun 2007
Posts: 534
Location: Mumbai
Send a message via Yahoo to prakash.raman
prakash.raman's Avatar
prakash.raman
Offline
Super Contributor
Hey antonio,
surely u can do this, use this api..

javax.microedition.lcdui.Image.createImage(Image image, int x, int y, int width, int height, int transform)

this takes ur first image as input and creat the new image using the height width that u want.

check its details in java doc.
Reply With Quote

#6 Old Re: Cut an image - 2007-09-20, 07:33

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
Just my 2 cents in what prakash.raman wrote. Try the next code:

Image smaller_image = Image.createImage(big_image, 0, 85, big_image.getWidth(), big_image.getHeight() - 85, Sprite.TRANS_NONE);

This should create a new image which will have the same width as a big one, and 85 pixels less in height. Note, that the Sprite class is defined in the package javax.microedition.lcdui.game
Reply With Quote

#7 Old Re: Cut an image - 2007-09-20, 12:17

Join Date: Mar 2007
Posts: 85
antonio5982
Offline
Regular Contributor
yes! It works.
Thank all of you for your help!

antonio
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
Opening a JPEG Image ummarbhutta Mobile Java Media (Graphics & Sounds) 8 2007-02-15 07:34
how to cut some part of Image mshouab Mobile Java Media (Graphics & Sounds) 2 2006-08-04 10:05
HELP: Mutable Image to Immutable Image? rj_cybersilver Mobile Java Media (Graphics & Sounds) 1 2005-03-26 10:58
Plz tell me easy method to cut image from the strip mwm786 Mobile Java General 1 2005-02-01 11:12
Nokia Image Converter davidpurdie General Discussion 0 2004-02-18 16:31

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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ