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 

[Lua Functions] Image Rotate & Image Scale

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



Joined: 29 Sep 2005
Posts: 11

PostPosted: Fri Oct 07, 2005 5:25 am    Post subject: [Lua Functions] Image Rotate & Image Scale Reply with quote

Here's some functions I came up with; I hope someone finds them useful.

Code:

function rotateImage(theImage)
   newImage = Image.createEmpty(theImage:height(), theImage:width())
   for x = 1, theImage:width() do
      for y = 1, theImage:height() do
         newImage:blit(y, x, theImage, x, y, 1, 1)
      end
   end
   return newImage
end -- rotateImage

function scaleImage(newX, newY, theImage)
   newImage = Image.createEmpty(newX, newY)
   for x = 1, newX do
      for y = 1, newY do
         newImage:blit(x,y , theImage, math.floor(x*(theImage:width()/newX)),math.floor(y*(theI  mage:height()/newY)), 1, 1)
      end
   end
   return newImage
end --scaleImage

--main program
smile = Image.load("smiley.png")
screen:blit(0, 0, smile)
screen:blit(100, 0, rotateImage(smile))
screen:blit(0,100, scaleImage(100,150, smile))
screen:flip()
screen.waitVblankStart(600)
Back to top
View user's profile Send private message
Zenurb



Joined: 30 Sep 2005
Posts: 106
Location: United Kingdom

PostPosted: Fri Oct 07, 2005 8:52 am    Post subject: Reply with quote

Probably get very slow with big images.
_________________
Proud Dvorak User
US 1.5 PSP (Original)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
arrggg



Joined: 29 Sep 2005
Posts: 11

PostPosted: Fri Oct 07, 2005 9:12 am    Post subject: Reply with quote

it's not that bad really.
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