I'm basically trying to take an Image Sequence and turn it into a Image Strip,
The code attempts to take the first image in the sequence, get the sequence number, then checks to see if the next file in the sequence exists, if it does, it acquires its pixmap pixel data, then it attempts to draw all of the acquired pixmap data to a single pixmap
Here's a link to a zip file containing a small image sequence http://bizzybud.com/files/comp1_00029.zip
''''TEMPORAREY'''''
Local FirstImagePath:String = "C:\Users\Ben\Desktop\AnimStrip\test\Comp 1_00000.png"
Local SavePath:String = "AAA.png"
'''''''''''''''''''
'breakdown file name structure
Local filename:String = StripDir(FirstImagePath)
'find how many in the . is
Local var1:Int = Instr(filename, ".")
'remove the .png
Local step1:String = Left(filename, var1 - 1)
'find how many in the _ is
Local var2:Int = Instr(step1, "_")
'remove everything before _
Local sequenceNumber:String = Right(step1, Len(step1) - var2)
Local sequenceName:String = Left(step1, var2)
'find out how many images are in the sequence
Local newNumber:String = sequenceNumber
Local Quit:Int = 0
While Not Quit = 1
'check if file exists
If FileType(ExtractDir(FirstImagePath) + "/" + sequenceName + newNumber + ".png") = 1
'acquire pixmap data
PixmapData.Acquire(LoadPixmap(ExtractDir(FirstImagePath) + "/" + sequenceName + newNumber + ".png"))
Else
Quit = 1
End If
'construct the name of the file to check
newNumber:String = String(Int(newNumber) + 1)
While Len(newNumber) < Len(sequenceNumber)
newNumber = "0" + newNumber
Wend
Wend
SavePixmapPNG(PixmapData.Draw(), SavePath, 9)
'''''''''''''''''''''''''''''''''''''''''''''''
'pixmapdata object holds all pixmap information
Type PixmapData
Global List:TList=CreateList()
Global Total:Int'number of pixmaps
Field Width:Int
Field Height:Int
Field Pixels:Int[9999,9999]
'Acquire the information of a pixmap
Function Acquire(thePixmap:TPixmap)
Local bPixmapData:PixmapData = New PixmapData
ListAddLast(PixmapData.List,bPixmapData)
PixmapData.Total = PixmapData.Total + 1
bPixmapData.Width = PixmapWidth(thePixmap)
bPixmapData.Height = PixmapHeight(thePixmap)
For x:Int=0 To PixmapWidth(thePixmap)-1
For y:Int=0 To PixmapHeight(thePixmap)-1
bPixmapData.Pixels[x,y] = ReadPixel(thePixmap,x,y)
Next
Next
End Function
'draw the data of each acquired pixmap and return the new pixmap
Function Draw:TPixmap()
Local newPixmap:TPixmap =CreatePixmap(10,10,PF_RGBA8888)'PixmapData.Width*PixmapData.Total,PixmapData.Height,PF_RGBA8888)
Local xStart:Int = 0
For aPixmapData:PixmapData = EachIn PixmapData.List
For x:Int=1 To aPixmapData.Width
For y:Int=1 To aPixmapData.Height
WritePixel(newPixmap,xStart+x,y,aPixmapData.Pixels[x,y])
Next
Next
Next
Return newPixmap
End Function
End Type
|