Hi I am trying to conert graphical code from blitzbasic to blitzmax, and I'm having a slight problem with drawing to (what was) imagebuffers.
In this code, every loop it simply brightens the blue value of each pixel in the image that isn't black.
Clicking the left mouse button should do nothing, but it is causing the image to "grow". New pixels are showing up when it is grabimaged.
I'm just wondering if there is any way to draw to an image, via grabimage, without getting new nonblack pixels around the edges.
Strict
Graphics 800,600
Local image:timage
Local x,y
Local pixmap:TPixmap
Local blue
'make the image
image=CreateImage(66,66)
SetColor 0,0,50
DrawRect 20,20,10,10
GrabImage image,0,0
Repeat
'brighten all nonblack pixels
pixmap=LockImage(image)
For y=0 Until image.height
For x=0 Until image.width
blue=ReadPixel(pixmap,x,y) & $FF
If blue>0 And blue<200 Then
WritePixel pixmap,x,y,$FF000000+blue+1
EndIf
Next
Next
UnlockImage image
'draw
SetColor 255,255,255
DrawImage image,0,0
Flip
Cls
If KeyHit(key_escape) Then End
'should do nothing...
If MouseHit(1) Then
Cls
DrawImage image,0,0
'this is where I would draw to the image.
GrabImage image,0,0
EndIf
Forever
|