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 

Resizing images

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



Joined: 05 Oct 2005
Posts: 87

PostPosted: Fri Nov 11, 2005 11:09 am    Post subject: Resizing images Reply with quote

Hey all. So far I've displayed and centered images in my image viewer using this -

Code:
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.

Is there some way to do this?
Back to top
View user's profile Send private message Send e-mail AIM Address
Durante



Joined: 02 Oct 2005
Posts: 65
Location: Austria

PostPosted: Fri Nov 11, 2005 11:12 am    Post subject: Reply with quote

Sure, use screen.blitScaled() in my version :P

But seriously, there's no scaling in standard LuaPlayer as of now that I know of. It would also be really slow if you do it in software.
Back to top
View user's profile Send private message
JoshDB



Joined: 05 Oct 2005
Posts: 87

PostPosted: Fri Nov 11, 2005 11:13 am    Post subject: Reply with quote

I found something kinda helped me.

Code:
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.

Thanks in advance for any help.
Back to top
View user's profile Send private message Send e-mail AIM Address
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Fri Nov 11, 2005 2:14 pm    Post subject: Reply with quote

I modified the code you posted above. It does not do some fraction. Only double, triple, etc. of a given image. Sorry.

Perhaps, the new version 0.12 would do the trick. I haven't taken a look into it, yet.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
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