Jump to content

Trouble with _GDIPlus_BitmapCreateFromFile not working


 Share

Recommended Posts

The following example works: But as soon as I use the line marked with # NOT WORKING instead of the screenCapture it doesn't show the image anymore.
 

Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH)  # WORKS
   ; Local $hHBmp = _GDIPlus_BitmapCreateFromFile( @ScriptDir & "\wallpaper.jpg" )   # NOT WORKING

    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp)
    _WinAPI_DeleteObject($hHBmp)

    local $hBitmap_Cropped =_GDIPlus_BitmapCloneArea($hBitmap  ,0, 0, 200,300, $GDIP_PXF24RGB)
    Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap_Cropped, 700, 400 * $iH/$iW)

    Local $hGUI = GUICreate("TEST", $guiW, $guiH, -1, -1)
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled , 0, 0)

Can anyone help me here?

Edited by kristo

Cheap, Fast, Good - Choose any two

Link to comment
Share on other sites

No need to convert to $hBitmap. It already $hBitmap.

;~    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH)
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile( @ScriptDir & "\wallpaper.jpg" )

;~     Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp)
;~     _WinAPI_DeleteObject($hHBmp)

    local $hBitmap_Cropped =_GDIPlus_BitmapCloneArea($hBitmap  ,0, 0, 200,300, $GDIP_PXF24RGB)
    Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap_Cropped, 700, 400 * $iH/$iW)

    Local $hGUI = GUICreate("TEST", $guiW, $guiH, -1, -1)
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled , 0, 0)

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...