Hello,
I use imageMagick dlls in c programming under windows, and I'd like to know how I could draw an image (or a part of) into a windows window, or into a canvas Handle.. ?
Thank you very much in advance
Best regards
Bob
draw image to a windows handle?
Re: draw image to a windows handle?
It's impossible with imageMagick??
Actually, I would like to create a windows application that could display imageMagick images into a window. That's why I would need direct drawing functions, or copyrect functions, so as to take fastly a rectangle from my image in memory, and copy it into my screen buffer..
How could I do?
Thank you very much in advance.
Best regards
Bob
Actually, I would like to create a windows application that could display imageMagick images into a window. That's why I would need direct drawing functions, or copyrect functions, so as to take fastly a rectangle from my image in memory, and copy it into my screen buffer..
How could I do?
Thank you very much in advance.
Best regards
Bob
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: draw image to a windows handle?
ImageMagick has a ImageToHBITMAP function which returns a bitmap handle from an Image pointer.
You will need:
and then:
You can then use this handle to display the image.
Pete
You will need:
Code: Select all
#include <magick/nt-feature.h>
Code: Select all
hbmp = ImageToHBITMAP((Image *)image);
Pete
Re: draw image to a windows handle?
Hi Pete,
thanks a lot for your reply! That function is interesting, but the problem is that if I'm using an image bigger than the available RAM memory (which is exactly what I wanted to use imageMagick for), as soon as I will convert my ImageMagick into a bitmap, it will crash.. So that's not a possible way to display it.
Any other clue?
Thanks a lot in advance.
Bob
thanks a lot for your reply! That function is interesting, but the problem is that if I'm using an image bigger than the available RAM memory (which is exactly what I wanted to use imageMagick for), as soon as I will convert my ImageMagick into a bitmap, it will crash.. So that's not a possible way to display it.
Any other clue?
Thanks a lot in advance.
Bob
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: draw image to a windows handle?
I know very little about how to display images with windows.
I would guess that one way would be (if you're using MagickWand) to use MagickGetImageRegion to extract a new wand with the region of interest, convert that wand to HBITMAP and then display it. But it's probably going to be slow.
If you can write image data directly to the window you could try using a pixel iterator (e.g. NewPixelRegionIterator) to extract the region you want.
Pete
I would guess that one way would be (if you're using MagickWand) to use MagickGetImageRegion to extract a new wand with the region of interest, convert that wand to HBITMAP and then display it. But it's probably going to be slow.
If you can write image data directly to the window you could try using a pixel iterator (e.g. NewPixelRegionIterator) to extract the region you want.
Pete
Re: draw image to a windows handle?
Hi Pete !
thanks again.
OK, both ideas don't seem to me very efficient, but if there isn't any other way to display imageMagick images, I will have to do that..
If I understand well, ImageMagick is not really suitable to handle images as a main image container in an application.
Thank you by the way for your answer.
Bob
thanks again.
OK, both ideas don't seem to me very efficient, but if there isn't any other way to display imageMagick images, I will have to do that..
If I understand well, ImageMagick is not really suitable to handle images as a main image container in an application.
Thank you by the way for your answer.
Bob
-
- Posts: 36
- Joined: 2010-02-21T18:02:40-07:00
- Authentication code: 8675308
Re: draw image to a windows handle?
Hi, in case it helps, to display images while debugging, I have:
1. Compress them losslessly to a temporary .tif file
2. Open this file in Windows Paint using system("mspaint ~temp.tif")
3. Delete the file from the hard drive
This has worked nicely for me. Note that the program is paused until you close windows paint!
1. Compress them losslessly to a temporary .tif file
2. Open this file in Windows Paint using system("mspaint ~temp.tif")
3. Delete the file from the hard drive
This has worked nicely for me. Note that the program is paused until you close windows paint!