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 

Loading a large image?

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



Joined: 21 Oct 2005
Posts: 12
Location: Ireland

PostPosted: Wed Apr 19, 2006 7:26 am    Post subject: Loading a large image? Reply with quote

I want to be able to load a map on to the screen.
image size is around 5000 by 5000.
i know the max size image is only 512 by 512.

how do i go about loading my map and be able to scroll around the map?
Back to top
View user's profile Send private message
KawaGeo



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

PostPosted: Wed Apr 19, 2006 8:13 am    Post subject: Reply with quote

Use your scissors. ;)

Can't resist.

PS Sorry...
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Wed Apr 19, 2006 10:31 am    Post subject: Reply with quote

This is nice solution you can use:
You cut the image into pisses (512X512 or what ever) and use this object
To do what ever you like. (Like image but a little bit different).

Code:

NewImage =
{
   Images = {},
}

-- Creates new image.
function NewImage:New()

   local c = {}

   setmetatable(c,self)
   self.__index =  self

   c.Images = {}
   return (c)
end

-- Loads image as part of the image in the x,y pos in the global image
function NewImage:LoadImage(x,y,str)

   local  img = Image.load(str)
   local tempImg = {}
   
   tempImg.Image = img
   tempImg.X = x
   tempImg.Y = y

   self.Images[table.getn(self.Images) + 1]  = tempImg
end

-- Draws the image on the img. x1,y1,x2,y2 is part of the image to draw..
function NewImage:Draw(x,y,img,x1,y1,x2,y2)

   local indx
   local maximg = table.getn(self.Images)

   if (x1 == nil) then

      x1 = 0
   end

   if (y1 == nil) then

      y1 = 0
   end

   if (x2 == nil) then

      x2 = img:width()
   end

   if (y2 == nil) then

      y2 = img:height()
   end

   for indx = 1,maximg  do

      local temp = self.Images[indx]

      local xx1
      local xx2
      local yy1
      local yy2

      if (temp.X >= x1) then

         xx1 = 0
      else
         xx1 = x1 - temp.X
      end

      if (temp.Y >= y1) then

         yy1 = 0
      else
         yy1 = y1 - temp.Y
      end

      if (temp.X + temp.Image:width() <= x2) then

         xx2 = temp.Image:width()
      else
         xx2 = x2 - temp.X
      end

      if (temp.Y + temp.Image:height()  <= y2) then

         yy2 = temp.Image:height()
      else
         yy2 = y2 - temp.Y
      end

      img:blit(x + temp.X ,y + temp.Y,temp.Image,xx1,yy1,xx2,yy2)
   end
end

-- blits image img to this new image.
function NewImage:blit(x,y,img)

   local indx
   local maximg = table.getn(self.Images)

   for indx = 1,maximg  do

      local temp = self.Images[indx]
      local ToDraw = true

      local xx1
      local xx2
      local yy1
      local yy2

      local xxx1
      local yyy1

      if (x >= temp.X) then

         xx1 = x -  temp.X
         xxx1 = 0
      else
         xx1 = 0
         xxx1 = temp.X - x
      end

      if (y >= temp.Y) then

         yy1 = y - temp.Y
         yyy1 = 0
      else
         yy1 = 0
         yyy1 =  temp.Y - y
      end

      if (x + img:width() <= temp.X + temp.Image:width()) then

         xx2 = img:width() - xxx1
      else
         xx2 = temp.Image:width() - xxx1
      end

      if (y + img:height() <= temp.Y + temp.Image:height()) then

         yy2 = img:height()  - yyy1
      else
         yy2 = temp.Image:height() - yyy1
      end

      temp.Image:blit(xx1,yy1,img,xxx1,yyy1,xx2,yy2)
   end
end

img = NewImage:New()
img:LoadImage(0,0,"1.png")
img:LoadImage(200,0,"2.png")
img:LoadImage(0,200,"2.png")
img:LoadImage(100,200,"1.png")
img:LoadImage(400,0,"1.png")

img:blit(160,190,Image.load("3.png"))

while true do

   img:Draw(0,0,screen,0,0,400,240)
   screen:flip()
end
Back to top
View user's profile Send private message Visit poster's website
DiabloTerrorGF



Joined: 15 Jul 2005
Posts: 64

PostPosted: Wed Apr 19, 2006 11:47 am    Post subject: Reply with quote

yos... you have a lot of free time, don't you?
Back to top
View user's profile Send private message
yossistarz2



Joined: 10 Apr 2006
Posts: 21

PostPosted: Wed Apr 19, 2006 8:19 pm    Post subject: Reply with quote

Well I am on a holly day ^_^.
So … yes.

But the question is if it helps?
Back to top
View user's profile Send private message Visit poster's website
tmaster



Joined: 21 Oct 2005
Posts: 12
Location: Ireland

PostPosted: Thu Apr 20, 2006 12:03 am    Post subject: Reply with quote

Great work thanks.
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