| Reply | « Previous Thread | Next Thread » |
|
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. |
|
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.
|
| EvilCartman |
| View Public Profile |
| Find all posts by EvilCartman |
|
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. |
|
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());
}
|
| EvilCartman |
| View Public Profile |
| Find all posts by EvilCartman |
|
thats right .. not working in the emulator .. but still working on the phone
|
| andreas mank |
| View Public Profile |
| Find all posts by andreas mank |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|