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 Resizeing

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



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sat Mar 17, 2007 9:44 am    Post subject: Image Resizeing Reply with quote

Is there any easy way to resize an image down to a certain specified size?

Possibly a 3d way to do that?
Back to top
View user's profile Send private message
cools



Joined: 04 Mar 2006
Posts: 46

PostPosted: Sun Mar 18, 2007 2:47 am    Post subject: Reply with quote

There is a way to do it. I think someone posted this function, I just modified it a bit.

Code:
function scaleImage(newX, newY, theImage)
newImage = Image.createEmpty(newX, newY)
   for x = 0, newX do
      for y = 0, newY do
         newImage:blit(x,y , theImage, math.floor(x*(theImage:width()/newX)),math.floor(y*(theImage:height()/newY)), 1, 1)
      end
   end
   return newImage
end
image = Image.load("blah")
scaledimage = scaleImage(newx,newy,image)


If you wanted to use the Gu/Gum functions to scale the image you would need to add sceGumScale() to lua player.
Code:
static int lua_sceGumScale(lua_State *L) {
   int argc = lua_gettop(L);
   if (argc != 3) return luaL_error(L, "wrong number of arguments");
   ScePspFVector3 v;
   v.x = luaL_checknumber(L, 1);
   v.y = luaL_checknumber(L, 2);
   v.z = luaL_checknumber(L, 3);
   sceGumScale(&v);
   return 0;
}

and {"scale", lua_sceGumScale}, in the correct spot


and then to scale the image, lets say 2x, in lua after your regular 3d stuff:
Code:
Gum.scale(2,2,1)


It will resize the x and y by 2 and keep the z the same.

You can expect to see the function in lua player mod 4.
Back to top
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Mon Mar 19, 2007 5:43 am    Post subject: Reply with quote

Thanks!
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 Lua Player 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