Im not sure if its me, who have been up for to long with no sleep and very little food... but i simply dont anderstand what the hell is going on here.
Here is what i was trying to do:
i was working on a game where the landskape was fully destructable, and i was having some huge problems with transparans on a image created with CreateImage() and generated with WritePixel(), after tons of testing i found out that a combination of MaskPixmap() and reloading the image, solves it.
now, when i create holes in the terrain, i need to do it again, but now this very odd behavier appears... and i francly dont know what the hell is going on, well... take a look and see your self.
there is a 1500ms delay on purpuse, to see what happens from the first loop to the next.
now, if it is not obvious, The pixels are not supose to get bigger, there is only supose to be a square hole in top left corner, however... all the pixels gets huge ?:S
uhm... now... me need sleep ... -.-
note:
removing maskpixmap and loadimage from inside the paintHole removes the problem, however... as far as i can tell, i still need to use them for the transparans to work on the hole, even tho it dont seem to work in the source above :(
Here is what i was trying to do:
i was working on a game where the landskape was fully destructable, and i was having some huge problems with transparans on a image created with CreateImage() and generated with WritePixel(), after tons of testing i found out that a combination of MaskPixmap() and reloading the image, solves it.
now, when i create holes in the terrain, i need to do it again, but now this very odd behavier appears... and i francly dont know what the hell is going on, well... take a look and see your self.
there is a 1500ms delay on purpuse, to see what happens from the first loop to the next.
now, if it is not obvious, The pixels are not supose to get bigger, there is only supose to be a square hole in top left corner, however... all the pixels gets huge ?:S
uhm... now... me need sleep ... -.-
SeedRnd MilliSecs() Graphics 800,600 SetMaskColor(255,0,255) Global img:TImage = CreateImage(200,200,DYNAMICIMAGE|MASKEDIMAGE) Local pmap2:TPixmap = LockImage(img) For Local j:Int =0 To ImageHeight(img)-1 For Local i:Int =0 To ImageWidth(img)-1 If Rand(0,10)=1 Then WritePixel(pmap2,i,j, toARGB(255,0,255,255)) Else WritePixel(pmap2,i,j, toARGB(255,255,0,255)) EndIf Next Next pmap2=MaskPixmap(pmap2,255,0,255) UnlockImage(img) img = LoadImage(pmap2) Repeat Cls() DrawImage img, 100,100 paintHole(img,20,20) Flip() Delay(1500) Until KeyHit(KEY_ESCAPE) Function toARGB:Int(a:Int,r:Int,g:Int,b:Int) Return ((a Shl 24)|(r Shl 16)|(g Shl 8)|b) End Function Function paintHole(image:TImage, x:Int, y:Int) ' ... Local pmap:TPixmap = LockImage(image) For Local j:Int =0 To 50 For Local i:Int =0 To 50 WritePixel(pmap,i,j,toARGB(255,255,0,255)) Next Next pmap=MaskPixmap(pmap,255,0,255) UnlockImage(image) img = LoadImage(pmap) End Function
note:
removing maskpixmap and loadimage from inside the paintHole removes the problem, however... as far as i can tell, i still need to use them for the transparans to work on the hole, even tho it dont seem to work in the source above :(