Is GrabImage safe?
BlitzMax Forums/BlitzMax Programming/Is GrabImage safe?
| ||
I want to have a pixmap, and draw some text onto it using Ziggy's FontMachine. FontMachine itself does not seem to allow you draw directly onto Pixmaps, though I've asked on the BLIde forum and waiting a reply. In the meantime, I could achieve the same result by drawing to the backbuffer and using GrabImage but I seem to remember on some PCs, GrabImage, or it might have been GrabPixmap, didn't work for one reason or another. Anybody shed any light on this? Are either/both these commands to be avoided? |
| ||
I never encoutered any problem with GrabImage, besides the fact that it is very slow. And I usually test my games on 13 different computers (from the ones I have, to family and the ones at work) - so you can include nVidia, ATI and Intel chipsets on that test. Last edited 2011 |
| ||
I never encoutered any problem with GrabImage, besides the fact that it is very slow. I'm not bothered about speed as this is a one-shot thing. |
| ||
Here's some test code. Appreciate it if folks could give this a test - its self explanatory but, draw a load of random circles, grab an image, draw the grabbed image, ESC to exit. [edit] Updated to include time taken for GrabImage. I get ~360ms which is perfectly acceptable for what I'm using it for. Strict Graphics 800,600 For Local n:Int = 1 To 500 SetColor Rand(0,255),Rand(0,255),Rand(0,255) DrawOval Rand(0,800),Rand(0,600),Rand(10,50),Rand(10,50) Next Local img:TImage = CreateImage(512,512,1) Local grabtime:Int = MilliSecs() GrabImage(img,0,0) DebugLog MilliSecs() - grabtime + "ms taken to grab" Cls SetColor 255,255,255 While Not KeyDown(key_Escape) Cls DrawImage img,MouseX(),MouseY() Flip Wend Last edited 2011 |
| ||
DebugLog:74ms taken to grab laptop specs in sig. I can't remember for sure but I believe DrawPixmap and/or Last edited 2011 Last edited 2011 |
| ||
Never had a problem with grab image or grab pixmap. |
| ||
Hiya, Debuglog:300ms taken to grab on my laptop... Sony Vaio VGN-FW31M with Vista SP2 using DX9. EDIT :- changed the Debuglog to Print and ran in Release mode - got ~240ms. Last edited 2011 |
| ||
Looks okay here, a bunch of colored ovals. Times were 150 and 89 for debug and release. Five year old PC: Win XP with on-board nvidia 6100 ( I think ). |
| ||
Instead of Debuglog, use print, so you can test it without debug mode, which is much faster. DX7: 32ms on 'release mode' and 81ms on 'debug mode'. DX9: 47ms on 'release' and 172ms on 'debug' OGL: 46ms on 'release' and 84ms on 'debug' (Laptop, ATI X1300, 1Gb RAM, WinXP) Last edited 2011 |
| ||
Well, as said I'm not overly bothered about how long it takes (unless it takes, like, 5 seconds or something). That's the only reason I put the time check in there. The only thing I'm really interested in, is whether or not it works. :) |
| ||
If you need more speed, drawing from pixmap to pixmap with pixmap.paste() is much, much faster. I was doing a grabimage to generate a 'level preview' in my game... switched to pixmap.paste() and the time went from 150ms to 1ms! Too bad - afaik - pixmap.paste() doesn't take the alpha channel into account, otherwise it would be pretty handy! |
| ||
API calls for OpenGL's GrabImage:glReadPixels()API calls for D3D9's GrabImage: GetRenderTarget() CreateOffscreenPlainSurface() GetDC() BitBlt() LockRect() Check the compatibility for these API calls. The rest of code in these functions is plain BMax. |
| ||
Started a new thread here with an EXE to test for those who dont have blitzmax or can't be bothered copying/pasting. Can a mod lock this please? |