GrabImage may work also with "active" images...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2798
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

GrabImage may work also with "active" images...

Post by Michael Vogel »

I have made some small routines for sorting icons within a large bitmap (including alpha channel), when I checked the resuting images, they all where empty because GrabImage did not work when accessing an image after the StartDrawing command.

The example below works fine now, because I've inserted the three lines marked with '***' - would be nice, if the program would also work without them.
Another fine thing would be to have a flag to force GrabImage to use a certain image depth or/and to grab the alpha channel or not.

Code: Select all

Procedure delete(s.s,color)

	Protected i,n,x,y,m,x2,y2
	
	StartDrawing(ImageOutput(#IconBitmap))
	DrawingMode(#PB_2DDrawing_AllChannels)
	For i=CountString(s,",")+1 To 1 Step -1
		n=Val(StringField(s,i,","))
		
		While n<7999
			m=n+1
			x=n&31
			y=n>>5
			x2=m&31
			y2=m>>5
			x*64
			y*64
			x2*64
			y2*64
			n+1
			StopDrawing(); ***
			GrabImage(#IconBitmap,999,x2,y2,64,64)
			StartDrawing(ImageOutput(#IconBitmap)); ***
			DrawingMode(#PB_2DDrawing_AllChannels); ***
			DrawImage(ImageID(999),x,y)
		Wend
	Next i
	StopDrawing()

	SaveImage(#IconBitmap,"Check.png",#PB_ImagePlugin_PNG)
EndProcedure