Page 1 of 1

Paint Shop Pro 7 - splitting sprite sheet

Posted: Fri Apr 06, 2007 9:07 pm
by codefire
Hi.

I have a single sprite sheet (bitmap file) with a number of frames for an animation on it. I want to split the sheet so that each frame goes into a seperate bitmap file.

Does anyone know how I can do that in PSP or even MS Paint? Or is there some tool out there to do it?

Cheers,
Codefire

Posted: Fri Apr 06, 2007 11:22 pm
by codemaniac
I recall having seen a function like that in Jasc Animation Shop.. might be worth to look at..

Re: Paint Shop Pro 7 - splitting sprite sheet

Posted: Fri Apr 06, 2007 11:22 pm
by traumatic
I don't know about PSP but why don't you write a simple program in PB to
accomplish this task?

Something like this (not much more than pseudo-code):

Code: Select all

For y=0 To #imageWidth-1 Step #sliceWidth
  For x=0 To #imageHeight-1 Step #sliceHeight
    GrabImage(#originalImage, #sliceImage, x, y, #sliceWidth, #sliceHeight)
    SaveImage(#sliceImage, "slice" + Str(i) + ".bmp")
  Next
Next

Posted: Sat Apr 07, 2007 8:56 am
by codefire
codemaniac wrote:I recall having seen a function like that in Jasc Animation Shop.. might be worth to look at..
I was looking at it, but to be honest I'm rubbish at graphics :) I'll have another look....I'm sure there's a function in there to do it...somewhere...

Re: Paint Shop Pro 7 - splitting sprite sheet

Posted: Sat Apr 07, 2007 8:57 am
by codefire
traumatic wrote:I don't know about PSP but why don't you write a simple program in PB to
accomplish this task?

Something like this (not much more than pseudo-code):

Code: Select all

For y=0 To #imageWidth-1 Step #sliceWidth
  For x=0 To #imageHeight-1 Step #sliceHeight
    GrabImage(#originalImage, #sliceImage, x, y, #sliceWidth, #sliceHeight)
    SaveImage(#sliceImage, "slice" + Str(i) + ".bmp")
  Next
Next
Yes, I think that might actually be the easiest way for me! :)

Cheers!

Posted: Tue Apr 10, 2007 2:14 pm
by codefire
..and here for posterity is the actual code I used. It seems PureBasic makes things very easy :) Thanks Traumatic.

Codefire.

Code: Select all

#IMAGE_WIDTH = 480
#IMAGE_HEIGHT = 360
#CHUNK_WIDTH = 80
#CHUNK_HEIGHT = 60

Enumeration
  #original_image
  #new_image
EndEnumeration

filename.s = "ship05.bmp"
result.l

result = LoadImage(#original_image, filename)

If result

  For y=0 To #IMAGE_HEIGHT-1 Step #CHUNK_HEIGHT
   For x=0 To #IMAGE_WIDTH-1 Step #CHUNK_WIDTH
     GrabImage(#original_image, #new_image, x, y, #CHUNK_WIDTH, #CHUNK_HEIGHT)
     SaveImage(#new_image, "BlueShip_" + Str(i) + ".bmp")
     i+1
   Next
  Next
  
EndIf