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 15, 2025, 07:32:37 PM
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.
So did a lot of members. There is not a lot of info about that on the forum. Most example code uses either plain gdi or uses gdiplus.
I just tried it as an experiment. Voila! It worked.  :azn:

¯\_(ツ)_/¯   :azn:

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

zedd151

#91
Quote from: jj2007 on March 15, 2025, 07:32:37 PM"\Masm32\examples\exampl04\car\car.jpg", fit  ; uses GdipDrawImageRectI, which stretches the image as desired
I didn't see that anywhere in the import names in olly for the 'car' example in the Masm32 SDK, I looked:
Names in car
Address    Section    Type    (  Name                                    Comment
00402000  .rdata    Import  (  gdi32.CreateCompatibleBitmap
00402004  .rdata    Import  (  gdi32.CreateCompatibleDC
00402008  .rdata    Import  (  gdi32.DeleteDC
0040200C  .rdata    Import  (  gdi32.SelectObject
00402010  .rdata    Import  (  gdi32.BitBlt
00402014  .rdata    Import  (  gdi32.DeleteObject
00402018  .rdata    Import  (  gdi32.GetDeviceCaps
00402020  .rdata    Import  (  kernel32.MulDiv
00402024  .rdata    Import  (  kernel32.SizeofResource
00402028  .rdata    Import  (  kernel32.SetLastError
0040202C  .rdata    Import  (  kernel32.LockResource
00402030  .rdata    Import  (  kernel32.LoadResource
00402034  .rdata    Import  (  kernel32.FindResourceA
00402038  .rdata    Import  (  kernel32.GetModuleHandleA
0040203C  .rdata    Import  (  kernel32.GetCommandLineA
00402040  .rdata    Import  (  kernel32.ExitProcess
00402048  .rdata    Import    ole32.CoTaskMemFree
0040204C  .rdata    Import    ole32.CoTaskMemAlloc
00402050  .rdata    Import    ole32.CreateStreamOnHGlobal
00402054  .rdata    Import    ole32.CoUninitialize
00402058  .rdata    Import    ole32.CoInitialize
00402060  .rdata    Import    oleaut32.OleLoadPicture
00402068  .rdata    Import  (  user32.LoadCursorA
0040206C  .rdata    Import  (  user32.GetSystemMetrics
00402070  .rdata    Import  (  user32.RegisterClassExA
00402074  .rdata    Import  (  user32.LoadIconA
00402078  .rdata    Import  (  user32.GetDC
0040207C  .rdata    Import  (  user32.DefWindowProcA
00402080  .rdata    Import  (  user32.CreateWindowExA
00402084  .rdata    Import  (  user32.BeginPaint
00402088  .rdata    Import  (  user32.UpdateWindow
0040208C  .rdata    Import  (  user32.MessageBoxA
00402090  .rdata    Import  (  user32.DispatchMessageA
00402094  .rdata    Import  (  user32.GetMessageA
00402098  .rdata    Import  (  user32.PostQuitMessage
0040209C  .rdata    Import  (  user32.EndPaint
004020A0  .rdata    Import  (  user32.ShowWindow
004020A4  .rdata    Import  (  user32.TranslateMessage
Nor any other gdiplus functions, unless OleLoadPicture does it internally.
That is one of the first examples I had looked at when looking for code to load images other than bitmaps. Seemed like a rather clunky way to load a jpg file, imo.
¯\_(ツ)_/¯   :azn:

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

NoCforMe

OK; so now we come to the matter of image quality. Does GDI or GDI+ yield the better image quality? Especially if the image is stretched?

I know that some rendering techniques result in really crappy images, but I can't remember exactly which ones those were.
Assembly language programming should be fun. That's why I do it.

zedd151

I have noticed that shrinking a large image with StretchBlt results in crappy quality for some images. There would be black lines at some intervals upon resizing the window smaller (using the size borders). Ill run some tests with screenshots when I get the chance.

I would like to think that gdiplus functions would yield better results, being more modern than the legacy gdi functions. Testing that will also come at some later time.

Here is a quick one using StretchBlt. Original image size 1024x768
shrunk dynamically using the sizing border. (window edge)  Not black lines for this image, but... looks like crap.

original zipped and attached
¯\_(ツ)_/¯   :azn:

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

NoCforMe

Can you maybe do some side-by-side comparisons? like GDI in one window and GDI+ in the other?
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on March 16, 2025, 08:51:28 AMCan you maybe do some side-by-side comparisons? like GDI in one window and GDI+ in the other?
Yes, but that will take a little time to get the gdiplus code 'just right'. Time that I don't have today. Maybe in a couple days. Remind me if I don't post something here by Monday or Tuesday regarding quality in gdiplus. I forget a lot of things here lately.
¯\_(ツ)_/¯   :azn:

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

zedd151

#96
Quote from: sinsi on March 14, 2025, 04:48:14 AMMight try a bigger GIF with more frames next.
I played around with your program today, sinsi.
The gif I used here is not Transparent, I just wanted to see how well it displayed.

Is there any way to correlate the delay per frame in the code, to what the frame delay is in the gif file rather than a 'one size fits all' timer delay?
What I mean is, is there any way to get the information from the gif file, for the delay for each frame? As you might have noticed, I have only a slight clue about gdiplus functions. The MS documentation isn't a great help, either.

Screenshot of program


Original gif file... I had made this years ago, for use as an avatar on another forum.

¯\_(ツ)_/¯   :azn:

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

daydreamer

Is it possible make old moonlander game,but with rotating a image of moonlander,instead of original vectorgraohics ?
Old atari game from 1970"s running on 6502 1.8 mhz
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

zedd151

Quote from: daydreamer on March 21, 2025, 06:48:50 AMIs it possible make old moonlander game,but with rotating a image of moonlander,instead of original vectorgraohics ?
If you can get screenshots, sure. Maybe using DosBox or similar?
1. Just make all of the graphics elements into seperate bitmaps {taken from screenshot(s)}
2. Using mspaint or other similar tool to create each frame using the graphics elements created in step 1, incuding the background.
3. Use ImageReady, Gimp or similar program to create the animated .gif file from the indidual bitmaps (created in step 2) that represent the animation frames. There are undoubtedly other tools out now, that can do similar tasks. Even possibly do all of these within the same program.

Similar steps were used in creating the pacman gif file above.
¯\_(ツ)_/¯   :azn:

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

sinsi

Quote from: zedd151 on March 21, 2025, 04:00:47 AMIs there any way to correlate the delay per frame in the code, to what the frame delay is in the gif file rather than a 'one size fits all' timer delay?
What I mean is, is there any way to get the information from the gif file, for the delay for each frame? As you might have noticed, I have only a slight clue about gdiplus functions. The MS documentation isn't a great help, either.

I started to look into it but lost interest...

    invoke  GdipGetPropertyItemSize,GpImage,PropertyTagFrameDelay,addr delaysize
    invoke  GdipGetPropertyItem,GpImage,PropertyTagFrameDelay,delaysize,addr delay

PropertyTagFrameDelay has more information, among other interesting stuff :biggrin:

zedd151

Quote from: sinsi on March 21, 2025, 07:15:06 AMI started to look into it but lost interest...
    invoke  GdipGetPropertyItemSize,GpImage,PropertyTagFrameDelay,addr delaysize
    invoke  GdipGetPropertyItem,GpImage,PropertyTagFrameDelay,delaysize,addr delay

Thanks sinsi, I'll look into that... eventually.  :smiley:
It's not an urgent need, but it might be useful in the future.
¯\_(ツ)_/¯   :azn:

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

jj2007


daydreamer

Quote from: zedd151 on March 21, 2025, 07:06:52 AM
Quote from: daydreamer on March 21, 2025, 06:48:50 AMIs it possible make old moonlander game,but with rotating a image of moonlander,instead of original vectorgraohics ?
1. Just make all of the graphics elements into seperate bitmaps {taken from screenshot(s)}
https://nasa3d.arc.nasa.gov/search/lunar
I have several 3d programs,so i can make old 3d pre-rendered graphics from 3d models, like baldurs gate
If you look thru 3d models, background could be made from one of landing sites

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

zedd151

#103
If it is your own programs daydreamer (that you have the source code for), the simplest way for you would be to output .bmp files at certain intervals rather than the method I mentioned earlier. Then work with those .bmp files to compile your gif animation from.

That would effectively remove at least some of the work to be done manually.
Keep in mind that even compressed (optimized) .gif animations can get large (in file size) very fast.
Generally the frame rate should be between 10-15 frames per second. Along with any optimizations, this should help keep the file size down to an acceptable level.

Huge (in pixel dimensions) .gif animations tend to take much longer to display, and use up much more memory when doing so. (I have at some point, tested using full screen sized .gif animations; 640x480, 800x600, etc.)

The results are much slower animations regardless of desired frame rate. At least that has been my experience in the past. (Almost 20 years ago)

Have fun!  :biggrin:

Later:
With today's faster processors and computers with tons of memory, results these days might be better, as far as using and displaying .gif animations with large dimensions and file sizes.
¯\_(ツ)_/¯   :azn:

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