Paint Shop Pro 7 - splitting sprite sheet

For everything that's not in any way related to PureBasic. General chat etc...
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Paint Shop Pro 7 - splitting sprite sheet

Post 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
codemaniac
Enthusiast
Enthusiast
Posts: 289
Joined: Mon Apr 02, 2007 7:22 am
Location: Finland

Post by codemaniac »

I recall having seen a function like that in Jasc Animation Shop.. might be worth to look at..
Cute?
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Paint Shop Pro 7 - splitting sprite sheet

Post 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
Good programmers don't comment their code. It was hard to write, should be hard to read.
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Post 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...
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Re: Paint Shop Pro 7 - splitting sprite sheet

Post 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!
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Post 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 
Post Reply