forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how can I get a pixel from a triImage?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Sat Sep 19, 2009 10:16 pm    Post subject: how can I get a pixel from a triImage? Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Sep 20, 2009 1:08 am    Post subject: Reply with quote

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
View user's profile Send private message
dridri



Joined: 31 Jul 2009
Posts: 35

PostPosted: Sun Sep 20, 2009 2:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Sun Sep 20, 2009 5:01 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group