how can I get a pixel from a triImage?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Heimdall
Posts: 245
Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:

how can I get a pixel from a triImage?

Post by Heimdall »

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?
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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'.
dridri
Posts: 34
Joined: Fri Jul 31, 2009 1:47 am

Post by dridri »

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...
Heimdall
Posts: 245
Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:

Post by Heimdall »

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!
Post Reply