LoadImageArea?

BlitzMax Forums/BlitzMax Programming/LoadImageArea?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

LoadAnimImage loads the whole image and then extracts the frames using TPixmap's Window and Copy method.

Here's the source code of LoadAnimImage:
	Function LoadAnim:TImage( url:Object,cell_width,cell_height,first,count,flags,mr,mg,mb )
		Local pixmap:TPixmap=TPixmap(url)
		If Not pixmap pixmap=LoadPixmap(url) 'this loads the <b>whole image</b>
		If Not pixmap Return

		Local x_cells=pixmap.width/cell_width
		Local y_cells=pixmap.height/cell_height
		If first+count>x_cells*y_cells Return
		
		Local t:TImage=Create( cell_width,cell_height,count,flags,mr,mg,mb )

		For Local cell=first To first+count-1
			Local x=cell Mod x_cells * cell_width
			Local y=cell / x_cells * cell_height
			Local window:TPixmap=pixmap.Window( x,y,cell_width,cell_height ) 'selects a specific part of the image into a new pixmap
			t.SetPixmap cell-first,window.Copy() 'copies the pixmap
		Next
		Return t
	End Function
So at execution time LoadAnimImage wouldn't be faster than manually loading the image and then copying a window. However, at the time of development LoadAnimImage will be faster, since it's only one single function you have to call, not a set of multiple functions and methods needed to do this task manually.