473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Load a bmp on to a GLview using CsGL

Vin
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 bd = b.LockBits(new Rectangle(0, 0, s.Width,
s.Height),ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
CsGL.OpenGL.GL.glReadPixels(0, 0, s.Width, s.Height,
CsGL.OpenGL.GL.GL_BGRA_EXT, CsGL.OpenGL.GL.GL_UNSIGNED_BYTE,
bd.Scan0);
b.UnlockBits(bd);
b.RotateFlip(RotateFlipType.Rotate180FlipX);
b.Save(@"c:\test.bmp", ImageFormat.Bmp);

Now I want to load the same test.bmp on click of a load button.
Can someone share a code snippet for the same. I guess we could use
glDrawPixels. But i m not sure how.

Help is much appreciated.

Cheers
Vin
Nov 16 '05 #1
3 4657
Vin,

Are you saying that you want to draw what you are drawing in the bitmap
to the button when it is clicked? If you want to do this, then you will
have to create the bitmap as you are doing now. Then, you would get the
Graphics object for the button (on the click), and draw the bitmap on the
graphics context for the button (through a call to the DrawImage method on
the Graphics instance).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vin" <kg*******@gmail.com> wrote in message
news:8c**************************@posting.google.c om...
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 bd = b.LockBits(new Rectangle(0, 0, s.Width,
s.Height),ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
CsGL.OpenGL.GL.glReadPixels(0, 0, s.Width, s.Height,
CsGL.OpenGL.GL.GL_BGRA_EXT, CsGL.OpenGL.GL.GL_UNSIGNED_BYTE,
bd.Scan0);
b.UnlockBits(bd);
b.RotateFlip(RotateFlipType.Rotate180FlipX);
b.Save(@"c:\test.bmp", ImageFormat.Bmp);

Now I want to load the same test.bmp on click of a load button.
Can someone share a code snippet for the same. I guess we could use
glDrawPixels. But i m not sure how.

Help is much appreciated.

Cheers
Vin

Nov 16 '05 #2
well, I've never used CsGL, but I assume the API is similar to good
ol' regular ogl.

Once you load the bitmap into memory (probably using a
System.Drawing.Bitmap), you probably want to map the texture onto a
quad or something

glBindTexture(GL_TEXTURE_2D, mybmp);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();

Hope that helps,
Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

kg*******@gmail.com (Vin) wrote in message news:<8c**************************@posting.google. com>...
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 bd = b.LockBits(new Rectangle(0, 0, s.Width,
s.Height),ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
CsGL.OpenGL.GL.glReadPixels(0, 0, s.Width, s.Height,
CsGL.OpenGL.GL.GL_BGRA_EXT, CsGL.OpenGL.GL.GL_UNSIGNED_BYTE,
bd.Scan0);
b.UnlockBits(bd);
b.RotateFlip(RotateFlipType.Rotate180FlipX);
b.Save(@"c:\test.bmp", ImageFormat.Bmp);

Now I want to load the same test.bmp on click of a load button.
Can someone share a code snippet for the same. I guess we could use
glDrawPixels. But i m not sure how.

Help is much appreciated.

Cheers
Vin

Nov 16 '05 #3
Vin
No Nick, I got a saved bmp on my hard disk. which i just want to load
on to the GLView. GLView is the graphics panel on which I want to load
the bmp file. GLView is from where I saved the drawn image
earlier.

Could you provide some code snippet to do this, just like the one I ve
posted for save?

Thanks
Vin
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Manasvin | last post by:
Just downloaded and tried it. Although very proto-type like, worth a look-see http://www.hamar.sk/sphere/ Manasvin
3
by: Arti Potnis | last post by:
Hi, I am trying to execute the DB2 load utility from a C program. lPid = fork(); execl(csExePath, csExeName,csCmd, NULL); the contents of the parameter variables are as follows:-
6
by: illmatic | last post by:
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. ...
1
by: Greg Patrick | last post by:
My problem: I load an some assemblies (strong named) from a byte array using Assembly.Load(byte). They load fine. But one one of them is actually accessed, it's referenced assemblies can't be...
2
by: **Developer** | last post by:
I have a Form (FV&C) containing a userconrtrol (CF&E) I do a ShowDialog for the form and the form's Load calls a method of the UserControl. The first time I do this the usercontrol appears on...
1
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...
3
by: Mark Thompson | last post by:
Hi, I have an application I have written in VB.NET. Part of the application is to display 3D models of buildings and allow the user to zoom and rotate around them. I have implemented this using...
0
by: swathiRasamallu | last post by:
I am using CsGL in C#.Net for graphical display.I want to rotate 2D triangle continuously.But i dont know how to do that in CsGL.In OpenGL we use glutidlefunction() for animations.What about CsGL?
13
by: rdudejr | last post by:
Hi all, I hardly ever make a post unless I am having a very purplexing issue, so this one should be good... I am trying to do a load against a database on an AIX server into a DB2 v9.1...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.