Solved

Output to a bitmap (needs to work with OpenGL)

Posted on 2004-03-26
6
452 Views
Last Modified: 2008-03-03
I am working on a ray tracer with OpenGL, and thinking about including an option to save the generated image to a, say, bitmap file. While looking around I have seen a few suggestions to include API calls (SetPixel, etc.), so I would like to know if anybody could show me how to properly incorporate such calls to realize this idea.

Thanks.
0
Comment
Question by:n_fortynine
  • 4
6 Comments
 
LVL 5

Expert Comment

by:info_expert
ID: 10695248
Ok you have to use the windows GDI Object. i.e. a bitmap.
First you have to create an empty bitmap. then you can set the value of any pixel by telling its location and color, using SetPixel and can also get the value of any pixel by using GetPixel().
0
 
LVL 5

Expert Comment

by:info_expert
ID: 10695263
You first create a DIBSection using pointer to a BITMAPINFO Structure variable (i.e. &bminfo):

hPBitmap=CreateDIBSection (NULL, &bminfo, DIB_RGB_COLORS, NULL, NULL, 0) ;
                              
hdc=GetDC(hwnd);
hdcMem = CreateCompatibleDC (hdc) ;
ReleaseDC(hwnd,hdc);
//Then you select the bitmap in memory context.            
SelectObject (hdcMem, hPBitmap) ;
now you can use SetPixel to set any pixel value.
You better see MSDN for set pixel
0
 
LVL 5

Expert Comment

by:info_expert
ID: 10695272
Ok, here is the method illustration:

SetPixel(hdcMem,x,y,RGB(redvalue,greenvalue,bluevalue));

Got?

Regards.
0
 
LVL 5

Accepted Solution

by:
info_expert earned 250 total points
ID: 10695276
0
 
LVL 4

Author Comment

by:n_fortynine
ID: 10695710
Thanks for the responses. I will look into them ASAP (when I get off work later tonight).
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

810 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