Author Topic: Bare Minimum GDIplus code to save different Image Types.  (Read 1676 times)

Siekmanski

  • Member
  • *****
  • Posts: 2314
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #30 on: April 29, 2020, 07:28:04 AM »
I don't have a clue, I had the same thoughts as you.
Maybe this works and sets the image size to 128*128 for the output image file?
Didn't test it ....

GdipGetImageThumbnail,pImage,128,128,addr pThumbnail,NULL,NULL
GdipSaveImageToFile,pThumbnail,offset FilenameW,offset clsidEncoder,NULL
Creative coders use backward thinking techniques as a strategy.

Siekmanski

  • Member
  • *****
  • Posts: 2314
Creative coders use backward thinking techniques as a strategy.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7530
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #32 on: April 29, 2020, 07:59:02 AM »
 :biggrin:

> Hope I didn't violate the 64 bit coding rules, else let me know......

Win 64 lets you know, if it runs, you have done something right, if it builds OK but does not run and dies silently, you have the PHUN of finding out why.  :tongue:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Siekmanski

  • Member
  • *****
  • Posts: 2314
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #33 on: May 06, 2020, 11:33:29 PM »
I'm working on saving PngIcons, this works very well.  :eusa_dance:
But saving Cursors (.cur) with embedded .Png images fails.
The resource compiler will not handle them.

I have done my research on finding cursor file specifications.
Some say cursors can have embedded .Png images, but without any file format specifications.
Others only say cursors have embedded .Bmp format with XOR / AND maps.

Anyone of you know more about this phenomena?
Or is it a fact, cursors can't have embedded .Png images?
Creative coders use backward thinking techniques as a strategy.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7530
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #34 on: May 07, 2020, 01:29:07 AM »
I think a cursor works similar to a bitmap and in the past I have seen icons used as bitmaps but I would imagine that however a cursor is created, it will have to be converted to cursor format. Its an old format that dates from the Win3.0 era and while later ones depending on the OS version can run coloured cursors, some of the older graphics card hardware did not support them.

If I need a custom cursor which is not very often, I use Axialis Cursor Workshop so if you need some samples to play with let me know.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Siekmanski

  • Member
  • *****
  • Posts: 2314
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #35 on: May 07, 2020, 02:01:56 AM »
Thanks, if I need them I'll let you know.  :thumbsup:
Creative coders use backward thinking techniques as a strategy.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7530
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #36 on: May 07, 2020, 12:44:03 PM »
Marinus,

Have a look at this link for cursor information.

https://en.wikipedia.org/wiki/ICO_(file_format)
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Siekmanski

  • Member
  • *****
  • Posts: 2314
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #37 on: May 07, 2020, 01:31:53 PM »
That's the page I based my PngIco code on.  :thumbsup:
Icon and cursor headers are almost identical, that's why it is strange the resource compiler chokes on cursor files.
Maybe the latest resource compiler can do the job?
Maybe you or someone else can provide me with the latest 2019-2020 RC.Exe and RcDll.Dll?
The one I have is from 2015.

I managed to crunch one of your icons from 16958 bytes to 5431 bytes without loss of alpha and color information.

BTW I found a work around to save the cursor as a compressed icon, load it as an icon and turn it into a cursor again in code.

in the wc:windowclass
Code: [Select]
    invoke  LoadIcon,hInst,100      ; Load a compressed PNG icon and turn it into a cursor
    invoke  GetIconInfo,eax,offset Icon_Info
    mov     Icon_Info.fIcon,FALSE   ; FALSE specifies a cursor
    mov     Icon_Info.xHotspot,0    ; The x-coordinate of a cursor's hot spot
    mov     Icon_Info.yHotspot,0    ; The y-coordinate of a cursor's hot spot
    invoke  CreateIconIndirect,offset Icon_Info
    mov     wc.hCursor,eax          ; Now it's a cursor...
I'm going to write an Image Tool so we can do all of this automated.

Here is the template for this tool where PngIcons are inserted and 1 converted to a cursor in code.
Also included your crunched Icon.
Creative coders use backward thinking techniques as a strategy.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7530
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #38 on: May 07, 2020, 06:06:58 PM »
Marinus,

Would using the following be better to allow for larger sizes ?

>     mov hIcon, rv(LoadImage,hInstance,10,IMAGE_ICON,64,64,LR_DEFAULTCOLOR)
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7530
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #39 on: May 07, 2020, 07:48:07 PM »
Here is an example of using LoadImage() where you can scale the cursor image up or down. The static cursor is a 32 pixel square RGBA type and I have scaled it up to 64 pixel.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Siekmanski

  • Member
  • *****
  • Posts: 2314
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #40 on: May 07, 2020, 09:20:49 PM »
Yes, I know this, but it does not solve the problem I have with the Resource Compiler (2015) on my computer.
It will not compile cursors with embedded .Png images.

So, my hope is in one of you who want to provide me with the latest Resource Compiler of 2019-2020.  :thumbsup:
Maybe this version can handle cursors I create with embedded .Png images.
Creative coders use backward thinking techniques as a strategy.

Vortex

  • Member
  • *****
  • Posts: 2327
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #41 on: May 07, 2020, 09:25:56 PM »
Hi Siekmanski,

You could try Pelle's resource compiler porc.exe

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7530
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #42 on: May 07, 2020, 09:26:51 PM »
Mine is the same version as yours, 2015. I have just picked out the vs2019 version and attached it.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Siekmanski

  • Member
  • *****
  • Posts: 2314
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #43 on: May 07, 2020, 09:33:07 PM »
Thanks guys, I will test it over a few hours.   :thumbsup:
Creative coders use backward thinking techniques as a strategy.

Vortex

  • Member
  • *****
  • Posts: 2327
Re: Bare Minimum GDIplus code to save different Image Types.
« Reply #44 on: May 07, 2020, 09:59:59 PM »
Hello,

There is also Jeremy Gordon's resource compiler GoRC  :

http://www.godevtool.com/