Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  converting an image using createRGBImage()  (Read 3302 times)
0 Members and 1 Guest are viewing this topic.
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Posted 2005-02-07 11:40:31 »

Hi all,

I'm having a few problems processing my images.  I've got the following method that takes an image and creates a int array to hold all the pixel values.  This seems to work fine, but it is when I need to recreate an image from this data that is posing a problem:

Image processImage(Image src) {
int w = src.getWidth();
int h = src.getHeight();

int[] pixels = new int[w*h];
src.getRGB(pixels,0,w,0,0,w,h);

// The following line seems to be throwing illegal argument exceptions:
Image dest = Image.createRGBImage(pixels, w, h, true);

return(dest);
}

I've tried to use the DirectGraphics and DirectUtils methods to draw the pixels but this results in Illegal State Exceptions.

Any help on this matter would be much appreciated!  It should be simple, but I'm not sure where I'm going wrong.

Regards,

ribot

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline davidaprice

Junior Devvie





« Reply #1 - Posted 2005-02-08 08:40:50 »

I wrote a quick test MIDlet to do this. It worked fine in the Wireless Toolkit and in the S60 Concept SDK emulator. However, it locked up my S60 & S80 phones so that both needed the batteries taking out to restart them Sad.  I've reported the, um, 'undocumented feature' to the guilty parties, but for now you may be out of luck...
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #2 - Posted 2005-02-08 08:57:24 »

Thanks for the feedback David!

I have found that it also locks my Nokia S60 emulator, and when locking in the phone the only way to reset is as you say to take the battery out.  Sad  Very scary.

I've played around with a few other things - I can get the method to work as long as the length of pixels is short enough. e.g. works at 5000 length with w = 176 and h = 30, but crashes at anything more.

I'm a bit surprised that no one has come across this before?

Regards,

ribot.

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #3 - Posted 2005-02-09 06:43:25 »

The only temporary solution I have come up with is as follows.  Basically, this method takes an image and returns an int[] array of pixel data with the alpha value amended.

int[] getRGBDataFromImg(Image src, int hexAlphaValue) {
                       
 int w = src.getWidth();
 int h = src.getHeight();
 int nPixels = w*h;

 int[] pixels = new int[nPixels];
 int[] srcPixels = new int[nPixels];
 src.getRGB(srcPixels,0,w,0,0,w,h);

 int tmpPixel;
 for(int i=0; i<nPixels.length; i++) {
   tmpPixel = srcPixels;
   pixels = hexAlphaValue | (tmpPixel & 0xff0000) | (tmpPixel & 0xff00) | tmpPixel & 0xff;

 }

 return(pixels);

So, I now having to temporarily use drawRGB() to draw 36600 pixels every frame which to say the least is quite slow!  :/  Could anyone offer any optimisations?  If anyone knows a way around the createRGBImage bug I would be most grateful if you could post.

Regards,

ribot

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline davidaprice

Junior Devvie





« Reply #4 - Posted 2005-02-09 09:25:27 »

Wish I could help, but I'm not having much luck. I tried using the Nokia UI API, i.e.:
1  
2  
Image newImage = DirectUtils.createImage(width, height, 0x00000000);
newImage.getGraphics().drawRGB(data, 0, width, 0, 0, width, height, true);

but my S60 phone hung in exactly the same way - it's probably implemented on top of the same bug.

Since you say it works with smaller images, would you be able to create several smaller horizontal slice images and draw them? Not pretty, but it might do the job.
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #5 - Posted 2005-02-09 09:30:12 »

I had thought about breaking up the one large image into 8 smaller ones, I'll conduct some more tests this afternoon.  Is there a known generic place on the web that contains a list of known bugs for nokia devices and some type of form to submit newly discovered bugs?

Many thanks for your help!

ribot

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline aNt

Senior Devvie




AFK


« Reply #6 - Posted 2005-02-09 18:58:47 »

ribot dude what are you doing in the JME mumble? get
back to web-sites and jogl u minx!  Grin
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #7 - Posted 2005-02-10 10:38:23 »

Mixing J2ME, JSP and Servlets (work) with Jogl and Cocoa (personal).  Cheesy
What are you up to these days?  You must have some handy hints for image processing optimisation lying around?  Cheesy

ribot

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline davidaprice

Junior Devvie





« Reply #8 - Posted 2005-02-11 07:02:39 »

Quote
Is there a known generic place on the web that contains a list of known bugs for nokia devices and some type of form to submit newly discovered bugs?

I don't know of one. Forum Nokia publishes a document called 'Known Issues in the Nokia 6600 MIDP 2.0 Implementation' that is certainly worth reading. If you want to report a bug to Nokia, probably the best place would be Forum Nokia's discussion groups. If you join Forum Nokia Pro (costs $$$s) you'll have better channels for communicating with Nokia.
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #9 - Posted 2005-02-11 16:24:45 »

Ok, thanks.  I'll download a copy of 'Known Issues in the Nokia 6600 MIDP 2.0 Implementation'.  I've been searching various forums and websites and it just seems strange that very few have come across the same problems.  Maybe they know better to not play with the createRGBImage function.  Cheesy

Many thanks for your help.

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (29 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (98 views)
2014-12-08 04:46:31

JscottyBieshaar (58 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (76 views)
2014-11-29 21:32:03

toopeicgaming1999 (137 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (37 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!