Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to create a bitmap for pictureBox

Posted on 2004-04-26
10
Medium Priority
?
987 Views
Last Modified: 2013-12-03
Hi all, I have a raw file in ppm standard (uncompressed, have RGB and header information of the width and height of the file).
I want to display it in my windows form but it seems that pictureBox does not accept PPM file.
Is there a way I can say if the file selected is a ppm file, i will create a bitmap object and put it into the pictureBox?

I checked around and believe that HBITMAP is gonna be the class object i will be creating the bitmap at.. but i am not sure how to set the R, G, B in the bitmap, (I assume its a 24bits/pixel)

What i will do is i will just read in the file stream, and set the R, G, B to the HBITMAP (or any other better choice??) object, then I will set it to the pictureBox(again, is there a way to directly set the item in pictureBox to a HBITMAP (or better choice?) object?

Thanks for any input..
0
Comment
Question by:lordiano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 

Author Comment

by:lordiano
ID: 10925630
Actually, I will do the checking for if the input file is a ppm file or a bmp..

I just need help on making a Bitmap object and help on setting the picturebox to display the bitmap object.
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10925652
on 'making' the Bitmap object, you might like to check this out:
http://support.microsoft.com/default.aspx?scid=kb;en-us;158898

regarding picturebox control, are you using .NET?
0
 

Author Comment

by:lordiano
ID: 10925679
Yes, I am running the application form in managed VC++
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10925729
if using .NET, and PictureBox1 is your picturebox control,
i think you can do this:

Image* imageFile = Image.FromFile("SampImag.jpg");
PictureBox1.set_Image(imageFile);
0
 

Author Comment

by:lordiano
ID: 10925994
Is there already a .DLL written to convert ppm file to HBITMAP?
cuz it seems that NVIEWLIB.DLL does the trick for jpeg and bmp files but i am just wondering if anyone knows any DLL that already does the trick for ppm to HBITMAP..
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10926041
you might be interested in this, FreeImage:
http://www.codeproject.com/bitmap/graphicsuite.asp
0
 

Author Comment

by:lordiano
ID: 10927670
Hi CoolBreeze, thanks for the link but unfortunately its not really what I wanted though, RIght now what i do was I created a Bitmap * mybmp
And i set the size of it according to the header information in the ppm file..
THen i use setpixel function to set each pixel in mybmp according the the ppm file.
Right now i am stuck on how to display this Bitmap * in my form.. or maybe my pictureBox , whichever is easier :)
Any idea?
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10927814
try something like:

Bitmap* MyImage = Image.FromHBitmap(hbitmap);
PictureBox1->Image = dynamic_cast<Image*>(MyImage);

?
0
 
LVL 3

Accepted Solution

by:
CoolBreeze earned 2000 total points
ID: 10927837
oops. since you already have the Bitmap, you can just go straight to the second line.
PictureBox1->Image = dynamic_cast<Image*>(MyImage);
0
 

Author Comment

by:lordiano
ID: 10928366
thanks CoolBreeze
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question