DatMCEyeBall Posted June 21, 2013 Posted June 21, 2013 How exactly would I load an image from the disk, draw a red cross from end to end and save it as a new image. I know to use _GDIPlus_GraphicsDrawLine but how? I already got the end to end bit down: The width and height is 500x350 Draw two lines at (0, 0, 550, 350) and (550, 0, 0, 350) respectively. "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
Geir1983 Posted June 21, 2013 Posted June 21, 2013 _GDIPlus_ImageLoadFromFile _GDIPlus_ImageGetHeight _GDIPlus_ImageGetWidth _GDIPlus_GraphicsDrawLine _GDIPlus_ImageSaveToFile Maybe?
DatMCEyeBall Posted June 21, 2013 Author Posted June 21, 2013 Ah, but what about _GDIPlus_ImageGetGraphicsContext? "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
UEZ Posted June 21, 2013 Posted June 21, 2013 (edited) Here an example: expandcollapse popup#include <GUIConstantsEx.au3> #include <GDIPlus.au3> $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.bmp;*.png;*.gif;*.tif)") If @error Then Exit _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sFile) If Not $hImage Then _GDIPlus_Shutdown() Exit EndIf Global $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Global $hGUI = GUICreate("GDI+ Test", $iW, $iH) ;no check when image is larger than screen! GUISetState() Global $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;only for display purposes Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGfx) Global $hImgContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;this is needed to copy the image to the bitmap and draw on it _GDIPlus_GraphicsDrawImageRect($hImgContext, $hImage, 0, 0, $iW, $iH) ;copy loaded image to bitmap (not display in GUI yet) Global $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000) ;create a brush AARRGGBB _GDIPlus_GraphicsFillRect($hImgContext, $iW / 2 - 10, 0, 20, $iH, $hBrush) ;draw filled rectangle of the image vertically _GDIPlus_GraphicsFillRect($hImgContext, 0, $iH / 2 - 10, $iW, 20, $hBrush) ;draw filled rectangle of the image horizontally _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap, 0, 0, $iW, $iH) ;copy modified image to graphic handle -> display it in the GUI _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Modified.jpg") ;clean up resources _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hImgContext) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ShellExecute(@ScriptDir & "\Modified.jpg") ExitBr,UEZ Edited June 21, 2013 by 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
DatMCEyeBall Posted June 24, 2013 Author Posted June 24, 2013 Works perfectly, thanks UEZ! "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
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