I wrote an example of a image veiwer, with it you can inlarge, shrink, flip, mirror,
rotate left, rotate right, brighen, dim, and gray the image.
the imageviewer will open bmp, jpg, gif files.
I include full source code, I would like to know if there is any problems
with the program so I could fix this example as I feel this example would be
good to show how to do many things with images.



Oh, and you can also download these examples at:http://www.masmwizard.com/about.php
Posted on 2006-05-24 02:36:19 by Zcoder
Seems to work pretty fine here (AMD64x2, XP/SP2) - if there's any memory leaks, they're so minor I haven't detected them. No per-file GDI or USER handle leaks. Other handles jump up a bit and down and seem a bit strange, but that might be a windows artifact rather than a bug with your code.

It would be nice with Ctrl+O for open and Ctrl+S for save, nice little example :)
Posted on 2006-05-24 06:30:37 by f0dder
There should be no leakes, I leak tested it. :lol:
The memory you see jumping up and down is becouse I wrote it to
do all actions in ram, avoiding GDI and only using  GDI when painting
the image. The ram is discarded after I flip, resize ect. then it is converted
back to a handle.

I can add the Ctrl+O for open and Ctrl+S for save.


Posted on 2006-05-24 06:37:24 by Zcoder
No no, not memory jumping up and down (well, probably does, but didn't look at that) - but regular handles jump up and down when loading an image. At first I thought it was a classic leak because the handle count increased when I opened a file... but then it stopped increasing, and suddenly it decreased again. But all "Handle jumping" involved opening a new file - weird :)

What did you use to leaktest?
Posted on 2006-05-24 06:49:23 by f0dder
I used MemProof, :lol:
I like that program couse it shows everything, I think. :D
about the opening a new file, I think it might be if you look
closer, DC's? I am not sure, it goes to fast to really see. :D


Posted on 2006-05-24 06:54:02 by Zcoder
I made some inprovements I added the CTRL+O and the CTRL+S
just as  f0dder, suggested, I also added the ability for the program
to take a file name as a param on the command line.
This also means that you can associate GIF, JPG, BMP to the
program, or you can test that feature by selecting open with.

Next I will add drag & drop, so you can drop an image in
to display it.

Posted on 2006-05-24 11:52:42 by Zcoder
The update now handles drag and drop, infact it handles
many image files at once to be droped into the client area.

So far the program seems to be leak free and stable.

Is there anything I have not thought about that I
should add? suggestions are welcome.


Posted on 2006-05-24 13:04:29 by Zcoder
I was playing with the program and found a small bug so I fixed it.

The bug was if you was in one screen mode and changed it while
you had a large image in it the titlebar was most of the time off
the top of the screen, so I fixed that problem as well.

Well, I can't find or think of anything else that could go wrong
or I can't think of anything alse to add to it, so I will wait for
some suggestions otherwise I will post this on my site as finished
and it should provide how to do this type of program.


Posted on 2006-05-24 14:12:05 by Zcoder
There's plenty of features you could add, but then you'd end up competing with ACDSee and the likes... I think it's good to "know when to stop", it's a good example and fairly useful program in it's own right as it is now :)
Posted on 2006-05-24 14:28:39 by f0dder
I think your right, If I continue to add more to it, I am not sure
if anyone can learn from it, as it would start to get to complex to study.

My aim was to make a somewhat complete program, (1) to show it can be
done in assembly (2) to present many things that you may or maynot have
known.(how to do it) (3) to contribute good examples (4) so I could have some fun.

I have desided this is what I want to do, make program examples that are in
them self complete, but yet not a complex full blown program.
it will be slow at first becouse it's not easy thinking up something complete
but yet small that presents good learning.

Any suggestions? LOL  :lol:

Posted on 2006-05-24 14:41:53 by Zcoder
Sounds like the way to go!

Nice to have you back here, and I hope any animosity of the past has been buried :)
Posted on 2006-05-24 14:44:06 by f0dder
All the animosity I ever had if any has left long ago. :lol:

Posted on 2006-05-24 14:49:14 by Zcoder
It doesn't work with that 44 meg jpg that was posted, but then I haven't found anything yet that does either. :-)

Posted on 2006-05-24 18:30:01 by skywalker
Hehe, I just tried it on the 44meg jpeg here :P.

It does seem to load (takes a while even on my dualcore beast), but the window resizes to some extremely small size. Manually resizing it, it's just black, and the "private bytes" usage is ~4meg - so the image "probably" fails to load.
Posted on 2006-05-25 10:34:44 by f0dder
For the life of me I can't really find why it won't do the 44 meg jpg file.
but I am still looking.  :D

Posted on 2006-05-25 12:59:06 by Zcoder

For the life of me I can't really find why it won't do the 44 meg jpg file.
but I am still looking.  :D


You're using the COM/OleLoadPicture stuff, aren't you? Might be some restrictions there.
Posted on 2006-05-25 13:03:23 by f0dder