Can someone post or give me a link to C# code that will allow me to
save what is currently being shown in my CsGL control to disk? Any
format will do, though bmp, jpg, or gif is preferred.
Thanks! 6 4923
illmatic wrote: Can someone post or give me a link to C# code that will allow me to save what is currently being shown in my CsGL control to disk? Any format will do, though bmp, jpg, or gif is preferred.
Bleh! Bleh!
--
Quaternion
Bleh bleh? Can you please help me out?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"illmatic" <ms******@wam.umd.edu> wrote in message Can someone post or give me a link to C# code that will allow me to save what is currently being shown in my CsGL control to disk? Any format will do, though bmp, jpg, or gif is preferred.
OpenGL has a glReadPixels that you can use to get the pixels that are shown
on the screen.
I haven't tried it, but if you initialize a Bitmap instance with the right
size and type [ie. RGBA] and then call the LockBits method, you may be able
to pass the Scan0 pointer of the BitmapData class directly to the
glReadPixels method as the pixels parameter. The only thing you have to do
then is to unlock the bits and call the Save method to save your image in
one of the supported formats.
Regards,
Pieter Philippaerts
Managed SSL/TLS: http://www.mentalis.org/go.php?sl
"Pieter Philippaerts" <Pi****@nospam.mentalis.org> wrote in message OpenGL has a glReadPixels that you can use to get the pixels that are
shown on the screen.
Here's some code that works, apart from the fact that the Bitmap is flipped:
Bitmap b = new Bitmap(width, height, PixelFormat.Format32bppArgb);
BitmapData bd = b.LockBits(new Rectangle(0, 0, width, height),
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
glReadPixels(0, 0, 1600, 1200, GL_BGRA_EXT, GL_UNSIGNED_BYTE, bd.Scan0);
b.UnlockBits(bd);
b.Save(@"c:\test.bmp", ImageFormat.Bmp);
You can call the b.RotateFlip method to flip the bitmap before saving.
Regards,
Pieter Philippaerts
Managed SSL/TLS: http://www.mentalis.org/go.php?sl
P.S.: for more information about glReadPixels, check out http://msdn.microsoft.com/library/en...unc03_8m7n.asp
I updated your code to follow CsGL syntax:
public void saveScene()
{
Size s = Size;
Bitmap b = new Bitmap(s.Width, s.Height,
PixelFormat.Format32bppArgb);
BitmapData bd = b.LockBits(new Rectangle(0, 0, s.Width, s.Height),
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
GL.glReadPixels(0, 0, 1600, 1200, GL.GL_BGRA_EXT,
GL.GL_UNSIGNED_BYTE, bd.Scan0);
b.UnlockBits(bd);
//b.RotateFlip();
b.Save(@"c:\test.bmp", ImageFormat.Bmp);
}
However, when I run this code, my computer hard resets! It’s the
strangest thing. Can you point out what I might be doing wrong?
Thanks…
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I hard coded the resolution while testing the code, but apparently I forgot
to change one of the lines before posting it here.
Try replacing the 1600 and 1200 in the call to glReadPixels with 'width' and
'height' respectively.
Regards,
Pieter Philippaerts
Managed SSL/TLS: http://www.mentalis.org/go.php?sl
"Michael Shafrir" <ms******@wam.umd.edu> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl... I updated your code to follow CsGL syntax:
public void saveScene() { Size s = Size;
Bitmap b = new Bitmap(s.Width, s.Height, PixelFormat.Format32bppArgb); BitmapData bd = b.LockBits(new Rectangle(0, 0, s.Width, s.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); GL.glReadPixels(0, 0, 1600, 1200, GL.GL_BGRA_EXT, GL.GL_UNSIGNED_BYTE, bd.Scan0); b.UnlockBits(bd); //b.RotateFlip(); b.Save(@"c:\test.bmp", ImageFormat.Bmp); }
However, when I run this code, my computer hard resets! It's the strangest thing. Can you point out what I might be doing wrong? Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dev |
last post by:
Dear Friends,
I am passing the image name, size (in bytes) and imgaeformat (like jpg or bmp or pdf) through the network.
I want display the image into picturebox without saving image...
|
by: Stu |
last post by:
I am working with C# in a .NET environment and I have written an
application using csgl. I need to display text on
the output viewport. I am displaying things with a
CsGL.OpenGL.OpenGLControl...
|
by: Vin |
last post by:
Hi,
I save the drwan stuff on a GLView using CsGL like this:
Size s = Size;
s.Width = 540;
s.Height = 435;
Bitmap b = new Bitmap(s.Width, s.Height,
PixelFormat.Format32bppArgb);
BitmapData...
|
by: Mats Boberg |
last post by:
Hi,
I have problems with saving a bitmap to hdd from my asp.net page
I get the following error: "A generic error occurred in GDI+."
Code:
Bitmap bmp = new Bitmap(240,120);
|
by: asad |
last post by:
Hello friends, how ru all, i have some problem about saving created
thumbnail, following is the code i use for creating thumbnail but thumbnail
was not saved it is on memory which method is used to...
|
by: Just close your eyes and see |
last post by:
Hi all
I am using CSGL Library , and when i am trying to make a debug build from
visual studio .net 2003 it succeeded , and when i am trying to make a release
build it failed and give me the...
|
by: Mark Denardo |
last post by:
Hi, I need some expert GDI+ person to help me with my RoundOffImage
Function:
What I'm trying to do is take in an image, crop off the edges around an
ellipse region I set up, and then return the...
|
by: Jerry Spence1 |
last post by:
I have an http command such as http://<ip-Address>/getimage to get a jpg
snapshot image from an IP camera. When I put this into a Web browser it
shows the image OK.
What I would like to go is to...
|
by: Mark Denardo |
last post by:
My question is similar to one someone posted a few months back, but I don't
see any replies.
Basically I want to be able to have users upload photos and save them in a
database (as byte data)...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |