Author Topic: GDI+ demo  (Read 2622 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8309
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GDI+ demo
« Reply #15 on: April 20, 2020, 09:48:53 AM »
OK, I have a question, I have an example that loads a BMP image and displays it on the client area which gives me a bitmap handle.

If I try to use the bitmap handle with,

    invoke GdipSaveImageToFile,bitmap,L(filename),rax,NULL

It will not start. If I put 0 as the first arg that app will at least run but the function does not work.

I don't know what is expected with the first argument, the reference material I have says a pointer to the image. What would you normally point at it ?
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 11419
  • Assembler is fun ;-)
    • MasmBasic
Re: GDI+ demo
« Reply #16 on: April 20, 2020, 11:41:08 AM »
Hutch,

the handle must be Gdi+, not Gdi:

GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBitmap** bitmap)

Creates a Bitmap::Bitmap object based on a handle to a Windows Graphics Device Interface (GDI) bitmap and a handle to a GDI palette.

https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-bitmap-flat

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8309
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GDI+ demo
« Reply #17 on: April 20, 2020, 02:18:42 PM »
Thanks, that worked correctly. I now have a function that will write an empty 0 length file to disk.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8309
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: GDI+ demo
« Reply #18 on: April 20, 2020, 03:29:07 PM »
It vurx, it vurx !!!! Like Frankenstein  :tongue:

Powered by Vortex, Siekmanski and JJ2007.  :biggrin:

I have done 3 different types, JPG, PNG and BMP. All seem to work OK.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

  .data
    CLSID_ImageType1 GUID <0557CF401h,01A04h,011D3h,<09Ah,073h,000h,000h,0F8h,01Eh,0F3h,02Eh>>
    pJPG@@@@@@ dq CLSID_ImageType1

  .code

; ------------------------------------------

SaveAsJPG proc bmHandle:QWORD,filename:QWORD

    LOCAL hGdip :QWORD

    invoke GdipCreateBitmapFromHBITMAP,bmHandle,0,ptr$(hGdip)
    invoke GdipSaveImageToFile,hGdip,L(filename),pJPG@@@@@@,NULL
    invoke GdipDisposeImage,hGdip

    ret

SaveAsJPG endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 2552
Re: GDI+ demo
« Reply #19 on: April 21, 2020, 05:24:14 AM »
That's great Hutch :thumbsup:

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 2552
Re: GDI+ demo
« Reply #20 on: April 26, 2020, 05:55:12 AM »
The BMP to PNG convertion example is translated to Poasm.