News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Bare Minimum GDIplus code to save different Image Types.

Started by Siekmanski, April 21, 2020, 06:08:10 AM

Previous topic - Next topic

Siekmanski

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

Aaahh, you want the zoomed portion to be saved.

Found this:
https://stackoverflow.com/questions/36821859/c-sharp-gdi-scaletransform-ok-on-picturebox-but-image-saved-is-original
Creative coders use backward thinking techniques as a strategy.

hutch--

 :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:

Siekmanski

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--

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.

Siekmanski

Creative coders use backward thinking techniques as a strategy.

hutch--

Marinus,

Have a look at this link for cursor information.

https://en.wikipedia.org/wiki/ICO_(file_format)

Siekmanski

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

    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--

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--

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.

Siekmanski

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

Hi Siekmanski,

You could try Pelle's resource compiler porc.exe

hutch--

Mine is the same version as yours, 2015. I have just picked out the vs2019 version and attached it.

Siekmanski

Thanks guys, I will test it over a few hours.   :thumbsup:
Creative coders use backward thinking techniques as a strategy.

Vortex

Hello,

There is also Jeremy Gordon's resource compiler GoRC  :

http://www.godevtool.com/