I'm trying to simply draw something on the backbuffer and then copy it to an image but it's not working. It's almost as though GrabImage isn't working as I can confirm the image is being drawn on the back buffer by uncommenting the line near the bottom of the function code.
Also, any idea why this version crashes, causing me to have to reboot?
Strict Graphics 800, 600, 32 Const TARG_IMAGE_FLAGS:Int = DYNAMICIMAGE | FILTEREDIMAGE | MASKEDIMAGE Global targ_image:Timage = create_target_image() While Not KeyHit(KEY_ESCAPE) Cls DrawImage targ_image, 100, 100 Flip Wend End Function create_target_image:Timage(size:Int=128) Local image:Timage = CreateImage(size, size, 1, TARG_IMAGE_FLAGS) SetClsColor 0, 0, 0 Cls Local rgb:Int = 0 For Local n:Int = 0 To 19 SetColor rgb, rgb, rgb DrawOval n, n, size-(n*2), size-(n*2) rgb :+ 10 Next rgb = rgb - 10 For Local n:Int = 30 To 49 SetColor rgb, rgb, rgb DrawOval n, n, size-(n*2), size-(n*2) rgb :- 10 Next 'Flip ; WaitKey() GrabImage image, 0, 0 Return image End Function
Also, any idea why this version crashes, causing me to have to reboot?
Strict Graphics 800, 600, 32 Const TARG_IMAGE_FLAGS:Int = DYNAMICIMAGE | FILTEREDIMAGE | MASKEDIMAGE Global targ_image:Timage '= create_target_image() While Not KeyHit(KEY_ESCAPE) Cls DrawImage targ_image, 100, 100 Flip Wend End Function create_target_image(size:Int=128) targ_image = CreateImage(size, size, 1, TARG_IMAGE_FLAGS) SetClsColor 0, 0, 0 Cls Local rgb:Int = 0 For Local n:Int = 0 To 19 SetColor rgb, rgb, rgb DrawOval n, n, size-(n*2), size-(n*2) rgb :+ 10 Next rgb = rgb - 10 For Local n:Int = 30 To 49 SetColor rgb, rgb, rgb DrawOval n, n, size-(n*2), size-(n*2) rgb :- 10 Next 'Flip ; WaitKey() GrabImage targ_image, 0, 0 'Return image End Function