Submit Your Own Code

PSP Lua CodeBase : Scale image

Description:
  This will resize any image.
You can download the luaLogo image here to use with the example.

-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Scale Image
-- SUBMITTED BY: bronxbomber92 (Edited by Charlie)

luaLogo = Image.load("lua.jpg")

function scaleImage(newX, newY, theImage) 

resizedImage = Image.createEmpty(newX, newY) 
for x = 1, newX do 
for y = 1, newY do 
resizedImage:blit(x,y , theImage,
math.floor(x*(theImage:width()/newX)),
math.floor(y*(theImage:height()/newY)),1,1) 
end 
end 
return resizedImage 

end

scaleImage(50,50, luaLogo) -- Resize image. 

while true do
screen:blit(100,10, luaLogo) -- Show the original image
screen:blit(100,110, resizedImage) -- Show the resized image

screen.flip()
screen.waitVblankStart()

end

Back to CodeBase
 

Please welcome daryy, our newest member.

Who's Online: 2 Guests, 0 Users

Total Members: 556
Total Posts: 13060
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: Lua 5.1.4 help. by daryy
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by yaustar
Re: Lua Loader? by Buddy4point0
Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl


Copyright © 2006-2007 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie