|
thank you very much. This is the first time I am getting a complete solution from Codeproject. cheers.
|
|
|
|
|
No problem!
I just realized I treated your source data as 16bpp when it's 32bpp (int!) LOL I'll change that.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Salsbery,
For the past one year the piece of code you gave me satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.
|
|
|
|
|
jossion wrote: modifying the code to colour
How many bits per pixel?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
8 bit per pixel in RGB format
|
|
|
|
|
I'm experiencing a wierd problem when capturing a screen from within a desktop app running on terminal server.
Here's my code:
Public Shared Function CaptureControlImage(ByVal pControl As Control, Optional ByVal pstrFilename As String = "") As System.Drawing.Image<br />
' Returns the image contained with the referenced controls client rectangle and optionally saves it to JPEG file<br />
<br />
Dim g As Graphics<br />
Dim picture As PictureBox<br />
Dim img As Image<br />
<br />
' Create a new PictureBox control. This is used to manipulate the captured bitmap<br />
picture = New PictureBox<br />
picture.Image = New Bitmap(pControl.ClientRectangle.Width, pControl.ClientRectangle.Height)<br />
<br />
' Create a GDI+ drawing surface based on the PictureBox control<br />
g = Graphics.FromImage(picture.Image)<br />
<br />
' BitBlt the screen image at the co-ordinates representing the referenced controls client rectangle<br />
' into the drawing surface, which is the PictureBox control<br />
g.CopyFromScreen(pControl.PointToScreen(New Point(pControl.ClientRectangle.X, pControl.ClientRectangle.Y)), _<br />
New Point(0, 0), _<br />
New Size(pControl.ClientRectangle.Width, pControl.ClientRectangle.Height))<br />
<br />
' Creates an image object from the PictureBox surface<br />
img = picture.Image<br />
<br />
If Not IsNothing(img) AndAlso pstrFilename <> String.Empty Then<br />
' Save the image to disk if required<br />
img.Save(pstrFilename, Drawing.Imaging.ImageFormat.Jpeg)<br />
End If<br />
<br />
Return img<br />
End Function<br />
It works just fine when running locally, but when the app is deployed on another server and it's access via terminal server, then this is what you get:
http://www.threefivefive.com/gallery/data/500/medium/capture_ts.jpg[^]
Can anyone tell me why?
|
|
|
|
|
Hi I have searched everywhere and cannot find a way to progamatically mirror the screen. What I need is to be able to look into a mirror at the screen and view it correctly. i.e Everything on the screen must be from right to left and not left to right. Thank you
|
|
|
|
|
Maybe this article will help you:
http://www.microsoft.com/middleeast/msdn/mirror.aspx[^]
you could copy the content of your screen to an image, flip this image and draw it back to the screen. no problem there, if you just want the screen to show everything mirrored. of course you won't be able to use the controls, since just the mirrored image is drawn back to the screen while the controls are still in their original place.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
modified on Thursday, February 28, 2008 5:43 PM
|
|
|
|
|
I want to ask one more thing that i am using this code ... where height is the Font height and startPoint_x and startPoint_y is the point where text is to be display
CsGL.OpenGL.GDITextureFont myGDITextureFont;
Font newFont;
newFont = new System.Drawing.Font("Microsoft Sans Serif", (float)height);
myGDITextureFont = new GDITextureFont(newFont, 'a', 'z');
GL.glTranslatef((float)startPoint_x, (float)startPoint_y, 0);
myGDITextureFont.DrawString(text);
and in this way text displayed but when i click on it it turns into solid bar .... What is the problem with this code ....
|
|
|
|
|
I am using C#, OpenGL and want to draw the Text on screen ... I went to OpenGL site and see the GLFont and other methods. Problem I face in these are:
They give Code in C++ that uses pointers and references that are not supported in C# and it call them as unmanaged code, i write unsafe modifier in front of it but other problem arises. So, these codes are not helpful unless they are in C# language.
if anyone know the method how to draw text in openGL or how to use C++ code in C# language then tell me .... I will be very pleased for your help ....
|
|
|
|
|
Yasir Nawazish Ali wrote: if anyone know the method how to draw text in openGL or how to use C++ code in C# language then tell me .... I will be very pleased for your help ....
one way[^]
another.[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Your First Link is not working .... But thanks for the Reply
I want to ask one more thing that i am using this code ... where height is the Font height and startPoint_x and startPoint_y is the point where text is to be display
CsGL.OpenGL.GDITextureFont myGDITextureFont;
Font newFont;
newFont = new System.Drawing.Font("Microsoft Sans Serif", (float)height);
myGDITextureFont = new GDITextureFont(newFont, 'a', 'z');
GL.glTranslatef((float)startPoint_x, (float)startPoint_y, 0);
myGDITextureFont.DrawString(text);
and in this way text displayed but when i click on it it turns into solid bar .... What is the problem with this code ....
|
|
|
|
|
Hi,
I need to render bitmaps really fast with great performance.
Since I at the same time need to do other CPU demanding operations it is prefered if the rendering can be handled as much as possible by the graphics card. But the rendering must perform ok even if there is no 3D support in the graphics card.
I have tried several rendering methods without coming to a conclusion.
I have tried these methods:
MFC:
----------------------------
CDC::StretchDIBits
CDC::StretchBlt
CDC::BitBlt
GDI:
----------------------------
SetDIBitsToDevice
DirectDraw:
----------------------------
IDirectDrawSurface7::BltFast
DirectX 9
----------------------------
IDirect3DDevice9::SetTexture
IDirect3DDevice9::StretchRect
ID3DXSprite::Draw
One method is by far fastest on all three systems I have tested with.
The system setup is similar for all three, except for the graphics cards:
Windows XP. service pack 2
Intel Pentium D CPU 3.40 GHz, 2GB Ram
The graphic cards differ accordingly:
1. Matrox Millenium G550. 32MB
2. Intel 82915. 128MB
3. Geforce8600GT 256Mb
The by far fastest rendering method is "IDirectDrawSurface7::BltFast".
It is also the only method which is slowest on system 1 with the worst graphics card, and by far fastest on system 3 with the best card.
Many of the other methods are worst on system 3, with the best graphics card!
However, I'am not very happy with using an old method from DDraw7, when there should be methods which are faster and more optimized for new graphic cards in DirectX 9. Furthermore BltFast does not support resizing.
But which method is this, that is best optimized for new graphics cards but also has good performance on computers with old graphics cards? And how do I use it to get the best performance and to minimize CPU usage, while letting the GPU do the work when supported by the graphics card?
What my application does is:
Retrieving several video streams on the network in MJPEG and MPEG4 format. Decoding the video to device independent bitmaps and finally rendering the bitmaps to screen in either original size, upscaled or downscaled. (An optional solution is to handle the resizing manually).
So the method has to be good at resizing the image, and I don't think I need any time consuming dubbel buffering, since I always draw the pictures in the same size at the same place once started.
Thanks for all help!
|
|
|
|
|
I have an algorithm which generates random 2D terrain shapes which are similar to those seen in the "Worms" game landscapes.
With such random shapes, how do I apply a texture to such random "curvy" shapes?
The GDI+ texture examples I've seen apply to regular shapes like rectangles but didnt cover how to apply textures to irregular shapes.
|
|
|
|
|
Floodfill[^] with a pattern brush?
But who is the king of all of these folks?
|
|
|
|
|
hi guys,
i want to start my career in web development.
kindly send me your suggestions about Design according to MICROSOFT STANDARDS.
My task is basically screen designing if u can share web templates.
i hope i will get soon suggestion from your side.
u can send your suggestion here or me4uonly@live.co.uk
thanks
bye
__________________________________________________
|
|
|
|
|
And why would we do this? We'd be complicit in helping you defraud your employer because you can't do the job and yet you're getting paid to do it. Tell you what - you can pay MY company to do this for you.
Or do you think your employer will be very pleased that you've just advertised a site that needs redesigning and admitted that your company isn't up to the task. How about if we got in touch with whites-stationery and let them know? Do you think they'd be pleased?
|
|
|
|
|
Dear Pete,
Thank you very much for your remarks, well if it is against the law to show any company name here then i will delete this question from here. i gave this name here as an example. i am not going to work on this site.
Actually i need free ASP.NET templates because i am a student and i want to work on stationary web site.
if u can help me then just reply me.
i hope you will help me in this regard.
take care
good bye
__________________________________________________
|
|
|
|
|
Saqib Yaqub wrote: Actually i need free ASP.NET templates because i am a student and i want to work on stationary web site.
if u can help me then just reply me.
i hope you will help me in this regard.
Ah, so in other words your homework assignement is to design a website for a stationary store and you want us to do your homework for you?
Doing my part to piss off the religious right.
|
|
|
|
|
Why not just google for free website templates? There are hundreds of sites that supply them.
|
|
|
|
|
In the *graphics* forum ?
You seem very confused to me.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: You seem very confused to me.
He can't decide whether he's employed or doing this as a project.
|
|
|
|
|
Hi,
I'm new to openGL programming. I'm trying to simulate motion and zooming in and out in an SimpleOpenGLControl from the Tao Framework. <so you="ll need to install the framework and put in a reference in Visual Studio to " tao=" in order to test my code">
I've just begun trying to move an object up and down, but i can't seem to get the object to move. i know i'm missing something but i can't figure it out. I think it has to do with loading the transformed coordinates into a new buffer and displaying the contents from the buffer... but i don't know how to do that.
Here's my code:
<br />
Imports Tao.OpenGl<br />
Imports Tao.Platform<br />
Imports Tao.FreeGlut<br />
<br />
Public Class frmMainWin<br />
<br />
Dim xTrans, yTrans, zTrans As Single<br />
<br />
Private Sub frmMainWin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
myGlWindow.InitializeContexts()<br />
myGlWindow.AutoSwapBuffers = True<br />
<br />
'init glwindow<br />
Gl.glClearColor(0.0F, 0.0F, 0.0F, 0.0F)<br />
<br />
'Glu.gluLookAt(<br />
Gl.glViewport(0, 0, 400, 300)<br />
Gl.glMatrixMode(Gl.GL_PROJECTION)<br />
Gl.glLoadIdentity()<br />
<br />
Gl.glOrtho(0.0, 10.0, 0.0, 10.0, -10.0, 10.0)<br />
Gl.glMatrixMode(Gl.GL_MODELVIEW)<br />
Gl.glLoadIdentity()<br />
<br />
xTrans = 0<br />
yTrans = 0<br />
zTrans = 0<br />
<br />
End Sub<br />
<br />
Private Sub myGlWindow_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles myGlWindow.Paint<br />
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT)<br />
<br />
Gl.glColor3f(0.2F, 0.2F, 0.8F)<br />
<br />
'Gl.glTranslatef(0.0F, 0.0F, 0.0F)<br />
Gl.glTranslatef(xTrans, yTrans, zTrans)<br />
Gl.glBegin(Gl.GL_TRIANGLES) 'Draw a triangle<br />
Gl.glVertex3f(0.5F, 1.0F, 0.0F)<br />
Gl.glVertex3f(0.0F, 0.0F, 0.0F)<br />
Gl.glVertex3f(1.0F, 0.0F, 0.0F)<br />
Gl.glEnd()<br />
<br />
End Sub<br />
<br />
Private Sub cmdUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUp.Click<br />
'MsgBox("up")<br />
yTrans = yTrans + 1<br />
<br />
myGlWindow.SwapBuffers()<br />
<br />
End Sub<br />
End Class<br />
Any help would be greatly appreciated.
Thanks
|
|
|
|
|
Hi,
do you invalidate the control somehow when changing yTrans? Otherwise, you won't notice any change. Check whether the Paint method is called at all using the debugger.
EDIT:
2 more things:
1.) Handle the Resize-Event and do the following:
Sorry, this is C#, but I don't really have an idea about VB. I guess this will help anyway:
<br />
private bool initialized = false;<br />
<br />
protected override void OnResize(EventArgs e)<br />
{<br />
if (initialized)<br />
{<br />
MakeCurrent();<br />
<br />
Gl.glViewport(0, 0, Width, Height);<br />
Gl.glMatrixMode(Gl.GL_PROJECTION);<br />
Gl.glLoadIdentity();<br />
Gl.glOrtho(0.0, 10.0, 0.0, 10.0, -10.0, 10.0);<br />
Gl.glMatrixMode(Gl.GL_MODELVIEW);<br />
Gl.glLoadIdentity();<br />
}<br />
}<br />
Also, make sure xTrans is not negative.
Last, why do you call SwapBuffers(), although you set AutoSwapBuffers to true before?
Hope this helps,
Chris
"Obstacles are those frightening things you see when you take your Eyes off your aim"
- Henry Ford
Articles
Blog
modified on Sunday, February 24, 2008 4:35 PM
|
|
|
|
|
Thanks for the information. I'll handle the resize event in a few.
Just checking...Is there any fault in not handling it?
What do you mean by "invalidate the control?"
About the swapping buffers issue... i was working with trial and error to try and see why my code wasnt working...thats why both are there (by mistake). I've removed the swapbuffers() fn now.
The solution to my problem i found was to clear the buffer and do 'myGlWindow.refresh' just after the transformation calculations. Don't know why it worked...may be you could explain it to me...
|
|
|
|