| View previous topic :: View next topic |
| Author |
Message |
Heimdall
Joined: 10 Nov 2005 Posts: 259 Location: Netherlands
|
Posted: Sat Sep 19, 2009 10:16 pm Post subject: how can I get a pixel from a triImage? |
|
|
I'm trying to use the triengine but I'm facing a dump problem when trying to read a simple pixel from the image.
I've load a png image, the image format reports it is IMG_FORMAT_8888 and the bits per pixel are 32. Now when i try to read a pixel in order to get it's color using:
triImage *collision = triImageLoadPng("collisionMap.png");
int bgColor = ((triU32*) collision->data)[collision->width
* y + x];
I'm geting wrong data (0 when it should be some gray value), what am i doing wrong? |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Sep 20, 2009 1:08 am Post subject: |
|
|
Not a solution but shouldn't bgColor be unsigned 32 bit?
And put parentheses around color->data as well. Cast applies only to the parent structure on the left otherwise and not to 'data'. |
|
| Back to top |
|
 |
dridri
Joined: 31 Jul 2009 Posts: 35
|
Posted: Sun Sep 20, 2009 2:52 am Post subject: |
|
|
I dont know the triEngine, but is there any colision->textureWidth ? or ->twidth ?
If yes, then :
triU32 bgColor = ((triU32*) collision->data)[collision->textureWidth * y +x]; _________________ I'm French, and 15 years old, so my English is not good... |
|
| Back to top |
|
 |
Heimdall
Joined: 10 Nov 2005 Posts: 259 Location: Netherlands
|
Posted: Sun Sep 20, 2009 5:01 am Post subject: |
|
|
yes i just went out for dinner and realized that i should be using image->stride instead of width. stride is the texture width on the triImage structure.
Thanks! |
|
| Back to top |
|
 |
|