Click here to Skip to main content
15,906,335 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In win32 application,I want to display image data,and these data be stored in memory, so I need a method what can direct read data from the memory and display image ,thanks a lot.
Posted
Comments
Sergey Alexandrovich Kryukov 22-Apr-13 21:38pm    
What do you mean by "image"? This term is too wide. Bitmap? Binary image of a disk? Application/code? What's the problem?
—SA
_naruto_liu_ 22-Apr-13 21:46pm    
First, I read a picture file to memory,after that display the picture from memory.
Mohibur Rashid 22-Apr-13 22:28pm    
What picture, there is various types of picture, win32 does not provide api for all of them. for bitmap follow this link
http://msdn.microsoft.com/en-us/library/windows/desktop/dd183385(v=vs.85).aspx
_naruto_liu_ 22-Apr-13 22:38pm    
png type of picture,but still thank you.
Mohibur Rashid 22-Apr-13 22:41pm    
if you are using mfc try CImage class
http://msdn.microsoft.com/en-us/library/bwea7by5%28VS.80%29.aspx

Use LoadImage[^] to load an image from file to memory.
You can then use GDI functions like BitBlt[^] to display the image from memory to the device context of a window or printer.

You can also use GDI+[^] for this.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Apr-13 23:34pm    
Basically, that's is, a 5.
—SA
If you are using a png image, Win32 does not offer a way to load that into memory. You have to use an external library, like LIBPNG[^] to load the image and convert it to a bitmap. Once you have a bitmap in memory, a simple BitBlt will get you there.

As an alternative, you might consider GDI+ as the previous post recommended. That requires for some Windows versions the instalation of the GDI+ DLL.
 
Share this answer
 
There is another way that you can try .
The api CreateFile can read an existing file to the memory .So , if you know more about the foamat of png and bitmap , you can do the transform by yourself .In this case ,just like you implements the function that include in the GDI+ DLLs .This is a difficult way ,but you can learn more about the picture format and you will use it effective. By the way ,windows just provide the Bitmap struct ,and not provide the struct of png . So ,you must define your png's struct by yourself .Good luck!!!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900