I have a question to the graphics gurus.
There are several ways to read the screen content starting from a simple
"GetPixelColour" to using the "Magnifier API" in Windows 7.
What are the best, fastetst and most relieble way to access pixels and graphics on the desktop and in other programms from my PB program?
How would you make your programm beeing able to see whats on the screen, for example to take a screenshot or something like that.
In Windows 7 i had the effect, that the "GetPixelColour" API could not ge the colours from an IE8 in "Safe Mode", while the Magnifier API could get everything.
Suggestions, Ideas or example code about this anybody?
This is the other way, we are not drawing - we are reading this time ...
I have explained this in my "SDK programming" section in the
XP AERO emulation to perform the Blur or Crystal effect when moving a skinned window hover the desktop.
QuotehDeskTop = GetDesktopWindow(): hDCSrce = GetWindowDC(hDeskTop)
In
zSkin.inc, search for
zGdipBlur, and instead of performing reduction apply a magnification factor.
...
Thanks, I'll take a look ...
SUB zGdipBlur(BYVAL hDCdest AS LONG, BYVAL xDest AS LONG, BYVAL yDest AS LONG, BYVAL xSrce AS LONG, BYVAL ySrce AS LONG, BYVAL xWidth AS LONG, BYVAL yHeight AS LONG)
LOCAL graphics, hDC1, hDC2, hBM1, hBM2, Img, xDiv, yDiv, nDiv, ImgAttr, hDeskTop, hDCSrce AS LONG
IF zDwmIsCompositionEnabled() THEN
IF SK_USEVISTABLUR() THEN
CALL zSetBlurBehindMode(zMainWindow(0), %TRUE, 0)
CALL zPaintBrushBitmap(hDCdest, 0, 0, xWidth, yHeight, zColorARGB(0, 0))
EXIT SUB
END IF
IF SK_USEVISTACRYSTAL() THEN
CALL zSetCrystalBehindMode(zMainWindow(0), %TRUE)
CALL zPaintBrushBitmap(hDCdest, 0, 0, xWidth, yHeight, zColorARGB(0, 0))
EXIT SUB
END IF
END IF
hDeskTop = GetDesktopWindow(): hDCSrce = GetWindowDC(hDeskTop)
nDiv = SK_AEROBLURLEVEL()
IF nDiv THEN
nDiv = nDiv + 1
xDiv = xWidth \ nDiv
yDiv = yHeight \ nDiv
hDC1 = CreateCompatibleDC(hDCdest)
hBM1 = zCreateDIBSection(hDCdest, xWidth, yHeight, 32)
CALL SelectObject(hDC1, hBM1)
' // Copy from DC source
CALL BitBlt(hDC1, 0, 0, xWidth, yHeight, hDCSrce, xSrce, ySrce, %SRCCOPY)
hDC2 = CreateCompatibleDC(hDCdest)
hBM2 = zCreateDIBSection(hDCdest, xDiv, yDiV, 32)
CALL SelectObject(hDC2, hBM2)
' // Perform reduction
IF GdipCreateFromHDC(hDC2, graphics) = 0 THEN
CALL GdipCreateBitmapFromHBITMAP(hBM1, BYVAL %NULL, Img)
CALL GdipSetInterpolationMode(graphics, 2)
CALL GdipDrawImageRectRectI(graphics, Img, 0, 0, xDiv, yDiv, 0, 0, xWidth, yHeight, %UnitPixel, ImgAttr)
CALL GdipDeleteGraphics(graphics)
CALL GdipDisposeImage(Img)
END IF
CALL zDeleteObject(hBM1)
CALL DeleteDC(hDC1)
' // Blur from reduction
IF GdipCreateFromHDC(hDCdest, graphics) = 0 THEN
CALL GdipCreateBitmapFromHBITMAP(hBM2, BYVAL %NULL, Img)
CALL GdipSetInterpolationMode(graphics, 2)
CALL GdipDrawImageRectRectI(graphics, Img, xDest, yDest, xWidth, yHeight, 0, 0, xDiv, yDiv, %UnitPixel, ImgAttr)
CALL GdipDeleteGraphics(graphics)
CALL GdipDisposeImage(Img)
END IF
CALL zDeleteObject(hBM2)
CALL DeleteDC(hDC2)
ELSE
CALL BitBlt(hDCdest, xDest, yDest, xWidth, yHeight, hDCSrce, xSrce, ySrce, %SRCCOPY)
END IF
CALL ReleaseDC(hDeskTop, hDCSrce)
END SUB