 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Gary13579
Joined: 15 Aug 2005 Posts: 93
|
Posted: Tue Nov 15, 2005 10:46 am Post subject: Image scaling |
|
|
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 |
|
 |
Ryu
Joined: 17 Oct 2005 Posts: 19
|
Posted: Tue Nov 15, 2005 10:52 am Post subject: |
|
|
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 |
|
 |
Ryu
Joined: 17 Oct 2005 Posts: 19
|
Posted: Tue Nov 15, 2005 11:00 am Post subject: |
|
|
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 |
|
 |
Gary13579
Joined: 15 Aug 2005 Posts: 93
|
Posted: Tue Nov 15, 2005 11:13 am Post subject: |
|
|
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 |
|
 |
Ryu
Joined: 17 Oct 2005 Posts: 19
|
Posted: Mon Nov 21, 2005 11:08 am Post subject: |
|
|
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 |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Mon Nov 21, 2005 5:13 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|