News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

gdiplus tests

Started by zedd151, March 12, 2025, 02:18:44 AM

Previous topic - Next topic

zedd151

Quote from: jj2007 on March 14, 2025, 07:42:07 AMis transparent (tweetie isn't)
I'm working on one that will be.  :tongue:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—


zedd151

Quote from: zedd151 on March 14, 2025, 08:24:39 AM
Quote from: jj2007 on March 14, 2025, 07:42:07 AMis transparent (tweetie isn't)
I'm working on one that will be.  :tongue:
Scratch that idea.
It had been so long that I had used ImageReady or Gimp to make transparent animated .gifs, I had forgotten much of what I once knew. Maybe some time in the future. A shame though, I have a 500 pixel wide clean copy of tweety in .gif with transparency. I fubarred my first several attempts so far. I might simply be missing a setting. They all had a white background.  :rolleyes:

from https://officialpsds.com/tweety-fun-gif-rvyz32
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Needs sound: "I tawt I taw a putty tat!".
Assembly language programming should be fun. That's why I do it.

zedd151

#79
Here is my latest, a few minor needed changes based on example in #1. No animations here though, Sorry guys.

First I put the gdip startup code into a procedure, is called from WM_INITDIALOG
Also, put the image loading code into a procedure, is called from WM_INITDIALOG as well

Added a routine using GetOpenFileName, to choose an image file upon program starup, rather than using a hard coded image name. Gets called after loading the image.

I added code to get the image size. The client area will now be automatically sized exactly to the image size. rather than using hard coded image dimensions.

Some issues linger regarding image size.  :rolleyes:  if too large or small... (larger than screen dimensions, smaller than minimized window client)
For the larger images, I *could* use scrollbars on the main window, with all the phun that it entails.  :toothy:

A few other errata also to attend to, before it's ready for prime time.
Another thing, this program does not handle images with transparency.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Interesting hybrid: you're using GDI+ to load image files and create handles to the bitmaps, but then you're using GDI (StretchBlt()) to actually display the image.

Was that intentional? does it work better for you that way?
Assembly language programming should be fun. That's why I do it.

zedd151

#81
Quote from: NoCforMe on March 14, 2025, 04:16:01 PMInteresting hybrid: you're using GDI+ to load image files and create handles to the bitmaps, but then you're using GDI (StretchBlt()) to actually display the image.

Was that intentional? does it work better for you that way?
At the time I first created it, I didn't know how to use gdi+ to do that. It worked fine like that, so I kept it.
Besides, I only really needed gdiplus only to load jpg,png,gif.etc. files. (Anything other than bmp's)
Why complicate simplicity?
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

daydreamer

Quote from: zedd151 on March 14, 2025, 04:36:56 PM
Quote from: NoCforMe on March 14, 2025, 04:16:01 PMInteresting hybrid: you're using GDI+ to load image files and create handles to the bitmaps, but then you're using GDI (StretchBlt()) to actually display the image.

Was that intentional? does it work better for you that way?
At the time I first created it, I didn't know how to use gdi+ to do that. It worked fine like that, so I kept it.
Besides, I only really needed gdiplus only to load jpg,png,gif.etc. files. (Anything other than bmp's)
Why complicate simplicity?
thats very helpful jpg,png directly used smaller files than uncompressed .bmp photos and no extra manually work convert files to .bmp's and gifs for cartoon and animations  :thumbsup:
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

Quote from: zedd151 on March 14, 2025, 04:36:56 PM
Quote from: NoCforMe on March 14, 2025, 04:16:01 PMInteresting hybrid: you're using GDI+ to load image files and create handles to the bitmaps, but then you're using GDI (StretchBlt()) to actually display the image.

Was that intentional? does it work better for you that way?
At the time I first created it, I didn't know how to use gdi+ to do that. It worked fine like that, so I kept it.
Besides, I only really needed gdiplus only to load jpg,png,gif.etc. files. (Anything other than bmp's)
Why complicate simplicity?

Why indeed?
It turns out that your choice of hybrid processing may be the easier one.
You could use GDI+ to display the image (at a fixed size) after opening it from a file, using GdipDrawImageRectI() in your WM_PAINT handler instead of StretchBlt(). In that case, 6 of one, half a dozen of the other.

However, if you wanted to also resize the image dynamically (in the WM_PAINT handler), then it'd take an extra step for GDI+; you'd need to use something like GdipScaleWorldTransform() first, then use GdipDrawImageRectI(), whereas with GDI you can use StretchBlt() to resize and display the image.

Good to know you can mix & match stuff here.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on March 15, 2025, 07:40:41 AMGood to know you can mix & match stuff here.
Yes. Before I first tried that, I wasn't certain that it would work. But alas, it did.  :biggrin:

One thing that I am not sure about. Would a gdiplus leak show up in task manager as a gdi leak? Or some form of memory leak? Or neither (something else)??
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Excellent question.
Wish I could answer it.
Process Explorer?
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on March 15, 2025, 07:54:31 AMExcellent question.
Wish I could answer it.
Process Explorer?
I might purposely not delete or dispose of any gdiplus related handles, to find out... then wait for a possible crash. All while watching task manager.
Then run the program in olly, if it had crashed in the previous run, to see if and where any exceptions occur. Some basic troubleshooting of a self inflicted injury.  :cool:  I'll report my findings.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Um, I don't think you're going to get a crash as a consequence of not releasing a few GDI/GDI+ objects. It's going to take a lot more than that to get to any kind of exception or crash due to resource depletion. I suppose you could do something in a loop that consumes lots of handles or other "objects".

Why not do that--not delete stuff--and then just use Task Manager to see how many GDI objects you have each time you run the app?
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: zedd151 on March 15, 2025, 08:09:42 AMI'll report my findings.
Okay, after commenting out the call here
    mov eax, lp_gdipBmp
    mov eax, [eax]                                                                  ;; get gdipBmp into eax (from lp_gdipBmp)
 ;    invoke GdipDisposeImage, eax                                                    ; dispose gdipBmp
No noticeable difference in gdi objects, no matter if minimized, maximized, or hidden behind other windows.
Arbitrary difference in memory usage. Or I should say either one could be a few hundred kb +- the other version. The version without that call, could be either a few kb more than the version with it, or vice versa. Without any rhyme or reason. Go figure.  :rolleyes:
Results of that test inconclusive. Also, no  crashes.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

jj2007

Quote from: NoCforMe on March 14, 2025, 04:16:01 PMthen you're using GDI (StretchBlt()) to actually display the image

GuiImage "\Masm32\examples\exampl04\car\car.jpg", fit  ; uses GdipDrawImageRectI, which stretches the image as desired

Quote from: NoCforMe on March 15, 2025, 07:40:41 AMGood to know you can mix & match stuff here.

I've always thought that Gdi+ handles are different from Gdi handles, but it seems they aren't. Good to know indeed.