Odd issue with pixmaps

BlitzMax Forums/BlitzMax Programming/Odd issue with pixmaps

Pineapple(Posted 2009) [#1]
I was writing some code on one computer, plopped it on my flash drive, worked on it on another, then brought it home. Now on my home computer, my pixmaps are failing to show. (why?) I'd say it was vista messing with me again, but one of the computers I worked on earlier also had vista, and it worked just dandy.


Any suggestions why this stuff would work on a couple computers but not another?


Arowx(Posted 2009) [#2]
Could it be the pixmap formatting or endianness settings did you change those?


Pineapple(Posted 2009) [#3]
How would those affect anything? No, I didn't


I didn't touch the pixmap code since I finished it, and it worked perfectly on one computer, I brought it home, and the pixmaps stopped displaying when I test ran it before doing anything to the code


Arowx(Posted 2009) [#4]
So you ran it on PC A fine, moved over to PC B worked on it fine then when you brought it back to A.

I presume when you mean pixmaps you are drawing/capturing your own images?

Are there any differences between the Gfx hardware of A and B?

Did you work on any to do with graphics when working on B?

Could you create a code sample that demonstrates the problem e.g. trimmed pixmap code?


Pineapple(Posted 2009) [#5]
No no,
ran it on PC A fine, moved over to PC B worked on it fine then when I brought it to PC C it didn't work

SuperStrict


'a bunch of globals I need for editing
Global choosetile:Byte=0,nowtile:Byte,tilr:Byte,tilg:Byte,tilb:Byte,lcol:Byte=0,rcol:Byte=0,tilscroll:Byte=0,updatetis:Byte=1
'relevant pixmap
Global seltilmap:TPixmap=CreatePixmap(18*4,18*4,PF_RGB888)
Function EditTile()
	SetColor 200,200,210;DrawRect 80,1,88,98
	If Not choosetile
		'Edit a tile; this code works fine
		
	Else 'choosetile is where a menu shows up that displays a grid of 4x4 tiles and you can scroll up/down along the list.
	     'drawing is sluggish if I draw all the tiles to the backbuffer every loop, so they're drawn to a pixmap and updated only when necessary.
	'make sure the pixmap exists. I declare the global after the main loop function, I think that's why it doesn't always get created initially
		If seltilmap=Null Then seltilmap:TPixmap=CreatePixmap(18*4,18*4,PF_RGB888) 
		Local xcor:Byte=0,ycor:Byte=0,overm:Byte=0
		'when updatetis=1 it means something outside of the tile edit dialog has been modified, 
		'and the pximap menu needs to be updated with the new data
		If upall Then updatetis=1
		If updatetis Then ClearPixels seltilmap,$FF797979 'SEE BELOW
		
		For Local x:Byte=tilscroll*4 To tilscroll*4+15 'write the tiles to the pixmap
			overm=MouseIn(xcor*18+83,4+ycor*18,16,16)
			If x>tile.num-1 Then Exit
			If updatetis Then WriteTile x,xcor*18+1,1+ycor*18,seltilmap
			If overm Then
				SetColor 0,0,0;DrawLine xcor*18+83,4+ycor*18+16,xcor*18+83+15,4+ycor*18+16
				If lmb Then nowtile=x;choosetile=0
			EndIf
			xcor:+1
			If xcor>3 xcor=0;ycor:+1
		Next
		
		DrawPixmap seltilmap,82,3 'draw the pixmap
		
		If updatetis=1 Then updatetis=0 'reset updatetis
		
		If Button("+",83,80,14,14) Then tile.Add 'misc. button adds another tile to the list
		
		'handle the scroll bar
		SetColor 30,30,30;DrawRect 159,4,7,18*4-2
		If Button("",159,3,7,6) Then tilscroll:-1;updatetis=1
		If Button("",159,18*4-3,7,6) Then tilscroll:+1;updatetis=1
		SetColor 255,255,255;DrawLine 161,6,163,6;Plot 162,5; DrawLine 161,18*4-1,163,18*4-1;Plot 162,18*4
		If tilscroll>Ceil(tile.num/4.0)-1 Then tilscroll=0
		If tilscroll<0 Then tilscroll=Ceil(tile.num/4.0)-1
	EndIf
End Function


'THis is my function I wrote to draw a tile onto a pixmap.
Function WriteTile(index:Byte,x%,y%,pmap:TPixmap)
	If index>tile.num-1 Then Return 'if the tile index is nonexistant (no tile has been created at the index), return.
	'NOTE: I can be sure that this line is not killing the drawing because the line ClearPixels seltilmap,$FF797979 marked 'SEE BELOW'
	'does not do its job, either.
	Local xcoord%=0,ycoord%=0
	For Local fx:Byte=0 To 63
		For Local bitpos:Byte=0 To 3
			'tilr, g, & b are 2-bit colors derived from a pallet. Ignore all the bit workings; they function properly.
			tilr=PeekByte(pallet.bank,NowPallet*12+ GetBits(PeekByte(tile.bank,fx+index*64),bitpos*2,2)*3 +0)
			tilg=PeekByte(pallet.bank,NowPallet*12+ GetBits(PeekByte(tile.bank,fx+index*64),bitpos*2,2)*3 +1)
			tilb=PeekByte(pallet.bank,NowPallet*12+ GetBits(PeekByte(tile.bank,fx+index*64),bitpos*2,2)*3 +2)
			SetColor tilr,tilg,tilb
			
			WritePixel pmap,x+xcoord,y+ycoord,($FF000000) | (tilr Shl 16) | (tilg Shl 8) | (tilb)
			
			'xcoord & ycoord track the location on the pixmap to write, since bank data is stored in a linear fashion.
			xcoord:+1
			If xcoord>15 Then xcoord=0;ycoord:+1
		Next
	Next
End Function



Brucey(Posted 2009) [#6]
You may have problems using DrawPixmap. It is entirely dependent on the Graphics driver working properly. It is also extremely slow, compared to DrawImage.

If you can get away with it, use DrawImage... otherwise you may experience issues.


Dabhand(Posted 2009) [#7]
Yeah, just quickly convert your pixmap over to an image if you need to:-

E.g:-

Local hPixmap:TPixmap = CreatePixmap(30, 30, PF_A8)

Local hImage:TImage = LoadImage(hPixmap)

DrawImage hImage, 0, 0


Dabz


Pineapple(Posted 2009) [#8]
works fine now, thanks for the help


CyBeRGoth(Posted 2009) [#9]
Aye thats an annoying problem, I assume you coded it on a winsows XP machine, then tried it on a vista one?

That had me stumped for a while a few weeks ago too, silly vista, roll on windows 7!


Arabia(Posted 2009) [#10]
Glad I'm not the only one that had this problem (posted a few months ago and Brucey from memory set me straight) :)

I was banging my head on a wall for ages over this :)