Geir1983 Posted July 30, 2013 Share Posted July 30, 2013 Hi Is it possible to crop a HBITMAP directly? I got it working by using GDI+ by converting to bitmap, copy wanted part, then convert back to hbitmp. #include <GDIPlus.au3> #Include <ScreenCapture.au3> _GDIPlus_Startup () $begin = TimerInit() ; Test, screenshot direct to hbitmap Local $hHBMP = _ScreenCapture_Capture('',0,0,@DesktopWidth,@DesktopHeight,False) ConsoleWrite("Creating _ScreenCapture_Capture hbitmap Desktop screenshot took " & TimerDiff($begin) & " milliseconds"& @LF) $begin = TimerInit() ; Test, Crop from hbitmap Local $hBMP= _GDIPlus_BitmapCreateFromHBITMAP($hHBMP) Local $hBMP_Cropped = _GDIPlus_BitmapCloneArea($hBMP, 0, 0, 110, 110) Local $hHBMP_Cropped = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_Cropped) ;_GDIPlus_ImageSaveToFile($hBMP_Cropped, $BMP3) ConsoleWrite("Creating cropped hbitmap Desktop screenshot took " & TimerDiff($begin) & " milliseconds"& @LF) Link to comment Share on other sites More sharing options...
UEZ Posted July 30, 2013 Share Posted July 30, 2013 Maybe _ScreenCapture_Capture(@ScriptDir & "\Cropped.jpg", 0,0,110, 110,False) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Geir1983 Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) No, you misunderstand. I want to create a "master" screenshot, directly to hbitmap. Later in my program i will use different parts from the master screenshot. The line with save cropped image to file was just for debug. Edit; my example does what i want, but is it neccessary to convert hbitmap to bitmap to do cropping? Edited July 30, 2013 by Geir1983 Link to comment Share on other sites More sharing options...
UEZ Posted July 30, 2013 Share Posted July 30, 2013 It should be possible to crop with GDI but I assume it is much more complicated to do it rather with the method you have posted. Why you are converting it back to HBitmap ($hHBMP_Cropped) again? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Geir1983 Posted July 30, 2013 Author Share Posted July 30, 2013 Ok ill just stick with that method then. I thought it might be an faster way to do it. I convert back to hbitmap because that is the input for other functions i use. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now