You Are Here:

Community: Developer Discussion Boards

#1 Old getPixels on Series60-Emulator does not work - 2004-01-23, 21:04

Join Date: Mar 2003
Posts: 14
Poldipold
Offline
Registered User
Hi!
`
Graphics g;
DirectGraphics dg;

g=cube[actualCube].getGraphics();
dg=DirectUtils.getDirectGraphics(g);

int format=dg.getNativePixelFormat();

short[] pixels=new short[cubeSize*cubeSize*4];
try {
dg.getPixels(pixels,0,cubeSize*4,0,0,cubeSize*4,cubeSize,format);
}
catch (Exception e) {
System.out.println("Exception(1): "+e+" "+e.getMessage());
}

This code does not what it should do. On every position of pixels[] there is -1 and nothing else. But there is an image in cube[actualCube]. I can see it on the display if it is painted. What can be wrong with this code?

Thanx in advance for any useful help

Cu - Thomas.
Reply With Quote

#2 Old 2004-01-28, 15:37

Join Date: Mar 2003
Posts: 61
Location: Merseyside
EvilCartman
Offline
Regular Contributor
you need to draw your cube image before grabbing the pixels

e.g
Code:
Graphics g;
DirectGraphics dg;

g=cube[actualCube].getGraphics();
dg=DirectUtils.getDirectGraphics(g);


g.drawImage(cube[actualCube], 0, 0, Graphics.TOP | Graphics.LEFT);


int format=dg.getNativePixelFormat();

short[] pixels=new short[cubeSize*cubeSize*4];
try {
dg.getPixels(pixels,0,cubeSize*4,0,0,cubeSize*4,cubeSize,format);
}
catch (Exception e) {
System.out.println("Exception(1): "+e+" "+e.getMessage());
}
Last edited by EvilCartman : 2004-01-28 at 15:43.
Reply With Quote

#3 Old 2004-01-29, 10:32

Join Date: Mar 2003
Posts: 14
Poldipold
Offline
Registered User
Hi!

Now I tried this:

Graphics g;
DirectGraphics dg;

Image tmpCube=Image.createImage(cubeSize*4,cubeSize);
g=tmpCube.getGraphics();
dg=DirectUtils.getDirectGraphics(g);
dg.drawImage(cube[actualCube],0,0,Graphics.TOP|Graphics.LEFT,0);

int format=dg.getNativePixelFormat();

short[] pixels=new short[cubeSize*cubeSize*4];
try {
dg.getPixels(pixels,0,cubeSize*4,0,0,cubeSize*4,cubeSize,format);
}
catch (Exception e) {
System.out.println("Exception(1): "+e+" "+e.getMessage());
}

... but: did not work. I really have no idea why :-((

Cu - Thomas.
Reply With Quote

#4 Old 2004-01-30, 11:36

Join Date: Mar 2003
Posts: 61
Location: Merseyside
EvilCartman
Offline
Regular Contributor
I think you need to use the same image object to create, get graphics and draw to.

like this:

Code:
Graphics g;
DirectGraphics dg;

Image tmpCube=Image.createImage(cubeSize*4,cubeSize);

g=tmpCube.getGraphics();
dg=DirectUtils.getDirectGraphics(g);


g.drawImage(tmpCube, 0, 0, Graphics.TOP | Graphics.LEFT);


int format=dg.getNativePixelFormat();

short[] pixels=new short[cubeSize*cubeSize*4];
try {
dg.getPixels(pixels,0,cubeSize*4,0,0,cubeSize*4,cubeSize,format);
}
catch (Exception e) {
System.out.println("Exception(1): "+e+" "+e.getMessage());
}
Reply With Quote

#5 Old right - 2004-02-17, 20:42

Join Date: May 2003
Posts: 2
andreas mank
Offline
Registered User
thats right .. not working in the emulator .. but still working on the phone
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

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