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

NoCforMe

Quote from: sinsi on March 12, 2025, 07:52:34 PMThe link gives an answer as to why
QuoteDECLARE INTEGER GdipDisposeImage IN gdiplus;
    INTEGER img 
Parameters:
img [in] Identifies the Image created by GdipLoadImageFromFile, GdipLoadImageFromStream and other Image constructors.
No it doesn't!
How is that in any way an explanation of what it does?
What does it mean to "dispose" [of] an image?
Since this is a different verb from "delete" or "destroy", it leads one to believe that it does something different from those actions. But what?
And when do we need to use this? with what types of "objects"?
Do you see how a real explanation of how this stuff works is what's needed (for us who don't know yet)?
Assembly language programming should be fun. That's why I do it.

sinsi

Jeez man, ever heard of a synonym?

To me, it's self-explanatory.
You create/load/bring into being an image from a file/stream/etc.
You dispose of/delete/destroy/kill it when you're finished using it.

That's a bit more information than MS give you.

TimoVJL

Have to understand OOP principles.
Every COM object have method Release and OOP object delete or ~
and other are just synonyms for same purpose.
I haven't found any good simple info for GDIPlusFlat API, that is for non-OOP languages.

Name GdipDisposeImage() quite is logical, it don't delete nor destroy that image, just release it's object and it's resources from memory.
May the source be with you

NoCforMe

Quote from: sinsi on March 12, 2025, 08:38:38 PMJeez man, ever heard of a synonym?

To me, it's self-explanatory.
You create/load/bring into being an image from a file/stream/etc.
You dispose of/delete/destroy/kill it when you're finished using it.

That's a bit more information than MS give you.

Is it, though? MS does say
QuoteReleases resources used by the Image object.

Which may seem obvious, but it's nice to at least have a hint, a clue as to what a function does ...
Assembly language programming should be fun. That's why I do it.

NoCforMe

I've reached a conclusion about using the GDI+ "flat" API:
The best way to figure out how to use this stuff (600+ functions) is, to use that internet abbreviation,
FAFO
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on March 12, 2025, 09:10:22 PMI've reached a conclusion about using the GDI+ "flat" API:
The best way to figure out how to use this stuff (600+ functions) is, to use that internet abbreviation,
FAFO

I had to look that up.  :joking:  :rofl:
It went right over my head.

Either that, or "fake it until you make it".  :tongue:

I guess I'll just stick to drawing lines, pixels, ellipses and rectangles, and more importantly polygons!  :biggrin:  :biggrin:
¯\_(ツ)_/¯   :azn:

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

jj2007

Calls used in my ImgPaintP proc (tested, no leaks); GdipDisposeImage and GdipDeleteGraphics are indeed the last actions required.
invGdip GdipCreateBitmapFromHBITMAP, eax, 0, esp
invGdip GdipCreateBitmapFromStream, #
invGdip GdipCreateBitmapFromHBITMAP, eax, 0, esp
invGdip GdipCreateHBITMAPFromBitmap, gsi.jjImgObject, addr gdiFil
invGdip GdipCreateFromHDC, ecx, addr gsi.jjGraphicsObj
invGdip GdipImageGetFrameDimensionsList, giImage, addr Dimensio
invGdip GdipImageGetFrameCount, giImage, addr DimensionIDs, add
invGdip GdipImageSelectActiveFrame, giImage, addr DimensionIDs
invGdip GdipGetPropertyItemSize, giImage, PropertyTagFrameDelay
invGdip GdipGetPropertyItem, giImage, PropertyTagFrameDelay, prop
invGdip GdipGetPropertyItemSize, giImage, PropertyTagDocumentName
invGdip GdipGetPropertyItem, giImage, PropertyTagDocumentName, pr
invGdip GdipGetPropertyItemSize, giImage, PropertyTagLoopCount, a
invGdip GdipGetPropertyItem, giImage, PropertyTagLoopCount, propS
invGdip GdipScaleWorldTransform, gsi.jjGraphicsObj, FP4(4.0)
invGdip GdipGetImageWidth, gsi.jjImgObject, esp
invGdip GdipGetImageHeight, gsi.jjImgObject, esp
invGdip GdipImageRotateFlip, gsi.jjImgObject, [edi.GuiImageZOOM].
invGdip GdipRotateWorldTransform, gsi.jjImgObject, FP4(45.0), Mat
invGdip GdipSaveImageToFile, giImage, ecx, eax, offset imgQuali
invGdip GdipDisposeImage, ebx
invGdip GdipDeleteGraphics, gsi.jjGraphicsObj

zedd151

#37
Quote from: jj2007 on March 12, 2025, 09:53:08 PMCalls used in my ImgPaintP proc (tested, no leaks); GdipDisposeImage and GdipDeleteGraphics are indeed the last actions required.

From what was posted here, I understand that GdipDeleteGraphics is definitely needed if GdipCreateFromHDC is called.

Which, in my exapmle  in #1 I do not use GdipCreateFromHDC .

Are there other gdip apis that would need GdipDeleteGraphics also?

When is GdipDeleteGraphics actually needed? Or is it a standard function that should always be called kinda like EndPaint?

I do call GdipDisposeImage, though. I think in the right place, too.

Listing 20+ apis, doesnt tell us what is definitely neeeded for a simple example as I posted in the original post here, jj2007.

I just want to know for now, if the code in that example is complete (as far as the gdip stuff) or is there an api call that is missing???

I am using gdi StretchBlt to do the actual drawing to the DC.
¯\_(ツ)_/¯   :azn:

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

daydreamer

My experience of memory leak in gdi, was long ago it worked a little while until all create pen and brush stopped working and program started to draw black and white
That why delete objects are important

"fake it until you make it".  :tongue:
It's so true in demo/game graphics development from slowest x86 faking it with luts and cheat like pseudo 3d and pre rendered 3d objects and light to new gaming computers making it with real time rendering with pixelshaders


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

TimoVJL

GdipCreateHBITMAPFromBitmap just create GDI bitmap, not object.
GdipDeleteGraphics is only for Graphics object.
GdipCreateBitmapFromFile create GpBitmap object, that you delete with GdipDisposeImage.
So a your GdipDisposeImage was in right place.
May the source be with you

zedd151

Quote from: daydreamer on March 12, 2025, 10:19:27 PMMy experience of memory leak in gdi, was long ago it worked a little while until all create pen and brush stopped working and program started to draw black and white
That why delete objects are important

"fake it until you make it".  :tongue:
It's so true in demo/game graphics development from slowest x86 faking it with luts and cheat like pseudo 3d and pre rendered 3d objects and light to new gaming computers making it with real time rendering with pixelshaders

Um. Okay. How does that answer a single question about GDI+?
GDI leaks are easily seen in Task Manager cause by not deleting the usual object (pens, brushes), and possibly not deleting memory DC. Or would that one be a memory leak??
I don't think that applies to GDI+ and it's apis.

There are no GDI leaks in my example, btw.
¯\_(ツ)_/¯   :azn:

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

zedd151

Quote from: TimoVJL on March 12, 2025, 10:22:15 PMGdipCreateHBITMAPFromBitmap just create GDI bitmap, not object.
GdipDeleteGraphics is only for Graphics object.
GdipCreateBitmapFromFile create GpBitmap object, that you delete with GdipDisposeImage.
So a your GdipDisposeImage was in right place.

Thank you for taking the time to look at my code. :azn:
Do I need to call GdipDeleteGraphics?

I am a bit mystified with this gdi+ stuff.
I had thought I had done enough research before posting the example. And I believe everything I need is already in the code.
¯\_(ツ)_/¯   :azn:

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

TimoVJL

No with #1 code, as Graphic object wasn't created in that code
May the source be with you

zedd151

#43
Quote from: TimoVJL on March 12, 2025, 10:32:29 PMNo with #1 code, as Graphic object wasn't created in that code
Thank you. That is all I needed to know at this time.

Now everybody...
See, this is what happens when you throw around function names that are not relevant to the topic at hand (meaning my example in post #1).

It causes major confusion to those trying to learn something new. In this case, ME. And NoCforMe as well.

Case closed for me, problem non existent, carry on.
Sheesh! Over 14 hours to finally get the answers that really mattered regarding my posted code.

Thread Closed!

Just kidding about that last one  :skrewy:

I am satisfied using BitBlt or StretchBlt to draw it to the DC. I ain't gunna try doing it with gdiplus at this time.  :smiley:

But to be clear, Timo.. if I do use a gdi+ API to draw to the DC, will I then need to use GdipDeleteGraphics?
¯\_(ツ)_/¯   :azn:

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

TimoVJL

Quoteto be clear, Timo.. if I do use a gdi+ API to draw to the DC, will I then need to use GdipDeleteGraphics?
Just in case, that you use GdipCreateFromHDC or similar function
May the source be with you