function ImageViewer(loc)
tempimage = Image.load(loc)
if tempimage:width() > 480 and tempimage:height() < 258 then
minusc = tempimage:width() - 480
elseif tempimage:height() > 272 and tempimage:width() < 481 then
minusc = tempimage:height() - 258
elseif tempimage:width() > 480 and tempimage:height() > 258 then
if tempimage:width() > tempimage:height() then
minusc = tempimage:width() - 480
else
minusc = tempimage:height() - 258
end
end
if minusc == nil then
tempcentx = tempimage:width()/2
tempcenty = tempimage:height()/2
else
tempcentx = tempimage:width() - minusc
tempcenty = tempimage:height() - minusc
tempcentx = tempcentx/2
tempcenty = tempcenty/2
end
centerx = 480/2 - tempcentx
centery = 258/2 - tempcenty
minusc = 0
while true do
screen:clear()
screen:blit(0,0,white)
screen:blit(centerx,centery,tempimage,0,0,tempimage:width() - minusc,tempimage:height() - minusc)
screen:blit(0,0,ivt)
button = Controls.read()
if button:cross() then
screen.waitVblankStart(10)
break
screen.waitVblankStart(1)
end
screen.flip()
end
screen.flip()
end
I thought screen:blit(centerx,centery,tempimage,0,0,tempimage:width() - minusc,tempimage:height() - minusc) would also resize the image, but no. It just displays certain portions of the image, and the rest is cut off.
function Image:magnify(mag)
mag = mag or 2 -- 2 times in size by default
local w = self:width()
local h = self:height()
local result = Image.createEmpty(mag*w, mag*h)
for x = 0, w-1 do
for y = 0, h-1 do
result:fillRect(mag*x, mag*y, mag,mag, self:pixel(x,y))
end
end
return result
end
But it resize by a fraction, and I haven't tested to see if it works for small fractions like 0.5.