create rows and columns in an animstrip
Blitz3D Forums/Blitz3D Programming/create rows and columns in an animstrip
| ||
http://www.blitzbasic.com/codearcs/codearcs.php?code=1288 Contains the code I am currently using but I want to make more than one column and row. Say 8 pic then go down to a new row. I've not gotten anything to work correctly. My sprite maker bogs down with pics containing more than 35 cells so I'm wondering if it's because they're all in one long row. Thanks. I'm sure it's easy. |
| ||
|
| ||
That's the idea, I'm having trouble figuring out how to implement it in the aforementioned code. Thanks. |
| ||
Nobody knows how to implement this? Any help would be greatly appreciated. |
| ||
to create a AnimImage, which has more than one row will serve nothing, because you cannot use this image as a animImage! If you want this, you will not get happy with this solution: But if you want to have an image with a lot of small tiles, you can make it this way: Graphics 800,600,0,2 AppTitle "Tile Image Creator" ; insert here the values of your choice: NumOfColumns = 3 NumOfRows=10 FrameWidth = 100 FrameHeight = 100 ImageName$ = "image" NewImage = CreateImage( FrameWidth*NumOfColumns, FrameHeight*NumOfRows) SetBuffer ImageBuffer( NewImage ) For Index = 0 To (NumOfColumns *NumOfRows)-1 X = Index Mod NumOfColumns y = Index / NumOfColumns ImageFrame = LoadImage( Imagename + Index+".bmp") DrawImage ImageFrame, FrameWidth*X, FrameHeight*Y Next SaveImage (NewImage, ImageName+"_All.bmp") End |
| ||
Actually midimaster you can use animimages with the frames laid out in more than 1 row. |
| ||
I was under the impression you could and that Blitz actually reads them better that way. Thanks for the code sample. I'll see if i can get it sorted out in my program. |
| ||
to create a AnimImage, which has more than one row will serve nothing, because you cannot use this image as a animImage! AnimImage DOES read multiple lines. When it reaches the end of a row, it will check for and continue on the next rows. I have no idea what might happen if the overall size of the imagestrip (table?) doesn't match a multiple of the frame height though, that may cause a bug or just leave cls-coloured space in the frame buffer. |
| ||
ok...thanks, I did'nt know that. So he could use my code for building multi line AnimImages.... The overallsize of the target picture would be a multiple of the frame dimensions |
| ||
Well, it's gonna take some rethinking because your code doesn't just plugin to mine. Here's the save routine as it now stands. I tried adding the NumofColumns and replacing my repeat until with your for/next but no luck.Case btn008 numofframes = TotalFrames framelength = 224 framewidth = 224 imagenum = 1 imagenum1 = 0 newimage = CreateImage(framewidth*numofframes,framelength,numofframes) SetBuffer ImageBuffer(newimage) Repeat imageframe = LoadImage(imagename$+imagenum+".bmp") ;ResizeImage imageframe,224,224 DrawImage imageframe,framewidth*imagenum1,0 imagenum = imagenum + 1 imagenum1 = imagenum1 + 1 Until imagenum = numofframes + 1 SetBuffer BackBuffer() Text 555,45,imagename$+".bmp, "+"your new AnimImage looks like this:" SaveImage (newimage,imagename$+".bmp") testanim=LoadAnimImage(imagename$+".bmp",224,224,0,TotalFrames) MaskImage testanim,255,255,255 While Not KeyHit(28) Cls UpdateGUI( ) Text 710,40,"Hit Enter to Stop" If MilliSecs() > tmrSparks + 100 Then tmrSparks=MilliSecs() frmSparks=( frmSparks + 1 ) Mod TotalFrames SendMessage( lbl002, "LM_SETTEXT", "Frame #: " + (frmSparks+1)) End If DrawImage testanim,642,102,frmSparks Flip Wend |
| ||
I think your problem mostly stems from how high the image needs to be. Do you know How many frames you want? Do you know what the sizes of the individual frames should be? There are limitiations on the size of any Buffer in blitz, I think it's something like 2048 pixels but don't quote me on that :) This means, that it may be necessary to adjust the output into less columns and more rows. Global MaximumWidthAllowed=((GraphicsWidth()*(GraphicsWidth()>2048)) + ((GraphicsWidth()<=2048) Shl 11) ) ; Not sure which of these is known??? Global TotalFrames=32 Global FrameEidth=224 Global FrameHeight=224 TotalWidth=Totalframes*Framewidth Rows=1 If (totalwidth>MaximumWidthAllowed) Over=(TotalWidth-MaximumWidthAllowed) TotalWidth=TotalWidth-Over Rows=Rows+1 End If Columns=TotalFrames/Rows TotalHeight=Rows*FrameHeight You now have tghe number of rows, number of columsn, and overal totalwidth and totalheight for the AnimImage. Which is a case of: Img=CreateImage(TotalWidth,TotalHeight) SetBuffer ImageBuffer(Img) For X=0 To Colums-1 For Y=0 To Rows-1 DrawImage AnimImage,X*FrameWidth,Y*FrameHeight,Y*Columns+X Next Next SetBuffer BackBuffer() SaveImage(Img,"MyImageYAY"+".bmp") Lastly, You don't need to do things such as numofframes = TotalFrames Just use the actual variables you have, substituting, say totalframes for numofframes etc. to match your original code. Hope this helps :) |
| ||
There are some errors in your code. Perhaps I did not understand right, ehat you plan to di, but if you want to paint a picture with more than one row...you HAVE to paint some tile in the second row Why did you replace the 'FrameHeight*Rows' with 'FrameLength'? newimage = CreateImage(framewidth*numofframes,framelength ??? ,numofframes)This will make the target image too small! Why did you replace it in painting too with the "0"? DrawImage imageframe,framewidth*imagenum1,0 ???This will paint all pictures in the first row, because Y-Value is always zero! How many tiles do you plan to add to the target image? What means "no luck"? What was the error you could see? Did you already try to open the target image with PAINT? Or did you have problem in opening it in an BB-Program? |
| ||
The current code I'm using is straight out of the archives. I referenced it in the original post. It works fine making animstrip that is just one long row. Not having written it though I can't totally explain how it works. I'm not a programmer, I just know enough to kind of string things together. Thanks so much for the time you're taking to help me out. It's not a big deal since my program works as it is but I don't know why animstrips bigger than 35 or so frames(224x224) tend to lock up the computer. Malice, the only knowns are the image size of 224x224. The totalframes are determined by how many frames the user draws or how many frames are in a loaded image. So the code needs to be dynamic more or less. numofframes and totalframes ???? maybe I could just use one variable but when I load an animimage I divide it's length by 224 to determine totalframes. I think originally I wanted two different variables to keep different code fragments more seperate. |
| ||
;example Graphics 500,500,0,2 CreateAnimStrip("Skully_SpaceShipA","Skully_AnimStrip",512,512,12,"png") End Function CreateAnimStrip(imagename$,savefile$,framewidth,frameheight,numberofframes,extension$="bmp") ;From parameters passed attempts to make an imagestrip, preferably square or near square ;the imagename$ must not contain the extension, the savefile must not contain the extension either, ;framewidth and frameheight are the width & height of individual frames ;numberofframes is the total number of images to be loaded and placed as frames ;extension refers to the input image, you can load .png etc if need be, don't pass the "." symbol ; Local numberofcolumns,numberofrows,widthindex,heightindex,index,image,newimage numberofcolumns=Floor(Sqr(numberofframes)) numberofrows=Ceil(Float(numberofframes)/Float(numberofcolumns)) newimage=CreateImage(framewidth*numberofcolumns,frameheight*numberofrows) For index=1 To numberofframes image=LoadImage(imagename+index+"."+extension$) If image<>0 Then CopyRect 0,0,framewidth,frameheight,widthindex*framewidth,heightindex*frameheight,ImageBuffer(image),ImageBuffer(newimage) FreeImage image EndIf widthindex=widthindex+1 If widthindex = numberofcolumns Then widthindex=0 heightindex=heightindex+1 EndIf Next SaveImage newimage,savefile+".bmp" FreeImage newimage Return End Function media here: http://home.swiftdsl.com.au/%7Etmalcolm/contentpack/spaceship/ You should be able to figure it out hopefully... |
| ||
Thanks Matty. I'll have to rework a lot of other code to accomodate the different function especially load animstrip but I should be able to get that going ok. Gives me something to work on today. Much appreciated. DOG |
| ||
Malice, the only knowns are the image size of 224x224. The totalframes are determined by how many frames the user draws or how many frames are in a loaded image. So the code needs to be dynamic more or less. numofframes and totalframes ???? maybe I could just use one variable but when I load an animimage I divide it's length by 224 to determine totalframes. I think originally I wanted two different variables to keep different code fragments more seperate. That's fine, since the code I posted will work still. It simply fills as much space as it can without 'breaking'. Just remove the declarations of the globals that aren't relevant. :) |