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 

Image scaling

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



Joined: 15 Aug 2005
Posts: 93

PostPosted: Tue Nov 15, 2005 10:46 am    Post subject: Image scaling Reply with quote

I've looked all over FileAssistant++ looking for how it scales images, but the source for that is huge and I can't figure out where it is.
I've also searched the forums many many times, and have only found a few Lua functions.

I need a function to scale images.. I've looked at sceGuTexScale in pspgu.h, but there is no documentation on it :(
I would also prefer if it did not loop through the image pixel by pixel changing the size, I want something fast, if possible.
Back to top
View user's profile Send private message
Ryu



Joined: 17 Oct 2005
Posts: 19

PostPosted: Tue Nov 15, 2005 10:52 am    Post subject: Reply with quote

is it to just display them? if yes then just use GL-like functions with proper vertex coordinates and u,v mapping;

example in 16bit:
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_5551|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);

and if you use
sceGuTexFilter(GU_LINEAR,GU_LINEAR);

then you'll have a bilinear resize even!
Back to top
View user's profile Send private message MSN Messenger
Ryu



Joined: 17 Oct 2005
Posts: 19

PostPosted: Tue Nov 15, 2005 11:00 am    Post subject: Reply with quote

oh yeah with sceGuTexScale(float scaleu,float scalev) you can scale the UV coordinates, actually if you're able to render a sprite on the screen that way (with a texture), then just play a bit with that function and you'll see the textures stretching, so you can use it to scale an image on the screen at least.

u coordinates are multiplied by scaleu
v ... scalev
Back to top
View user's profile Send private message MSN Messenger
Gary13579



Joined: 15 Aug 2005
Posts: 93

PostPosted: Tue Nov 15, 2005 11:13 am    Post subject: Reply with quote

I didn't understand much of that first post, I am pretty new to C :(

So what is scaleu/scalev? Would that just be the amount to scale it by?
If I am understanding correctly, then this
Code:

sceGuTexScale(1.0f, 1.0f);

Would keep the image at original size?
Back to top
View user's profile Send private message
Ryu



Joined: 17 Oct 2005
Posts: 19

PostPosted: Mon Nov 21, 2005 11:08 am    Post subject: Reply with quote

you should look at the examples of the pspsdk, namely the blit.c example.

basically you can draw a quad, let's say you give 4 coordinates
x,y (z=0)
-----------
A 0,0
B 480,0
C 480,272
D 0,272

you can draw that polygon using the sceGu library (similar to opengl), and you can use a texture, so you need to give the u,v mapping coordinates, ranging from 0 to 1 (left and right of the texture), the texture width must be a power of 2.

now imagine you want to zoom x2 on the image, you can just use u,v coordinates with half their values, it'll still draw it on the 480x272 quad...

sorry if it's not clear, and also the sceGuTexScale function is used to scale those u,v coordinates so the values that you give are not from 0 to 1 anymore, use sceGuTexScale(1.0/512,1.0/512) for example if you have a 512x512 texture, then use u,v coordinates corresponding to pixels that you want to draw, so if you want to draw the rectangle 20,10,100,50 on the 480x272 quad, just use u=20 for A and D, u=100 for B and C, v=10 for A and B, v=50 for C and D...

(might have to reverse a value or two if the image is flipped)
Back to top
View user's profile Send private message MSN Messenger
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Mon Nov 21, 2005 5:13 pm    Post subject: Reply with quote

Note that sceGuTexScale() and sceGuTexOffset(), and everything else involving transforms of the ST-coordinates (normalized) into UV-space has no effect when GU_TRANSFORM_2D is specified, what you feed the pipe is raw coordinates. This was incorrectly assumed in early versions of the blit-sample (since it was written back in july), the current one does not use those functions any more.

If you need to be able to transform your texture-coordinates using sceGuTexOffset/Scale(), setup a 2D ortho projection and go with GU_TRANSFORM_3D.
_________________
GE Dominator
Back to top
View user's profile Send private message
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