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 anthonyjee, our newest member.

Who's Online:

Total Members: 522
Total Posts: 13085
Total Topics: 1515
Total Categories: 7
Total Boards: 42

Recent Posts:

Re: Hello every body... by DeniseVera
Need help please by Robbynator
Re: Hello every body... by horvathann
Re: background criminal record check by backgroundchecker
background criminal record check by backgroundchecker
Intro to Perl Part 2: What are Scalars? & Examples by Chi Kitory
Intro to Perl Part 1 About Perl and Hello World by Chi Kitory
Re: Trying To Get Rid of the Spammers by Charlie


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