473,394 Members | 1,694 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,394 software developers and data experts.

Capture Control in Bitmap?

Hello!

I would like copy my control in a bitmap and after in a jpeg.
I have an error of gdi!
This is my code

System.IntPtr intPtr = this.RichTextBox.Handle;
System.Drawing.Image img = Bitmap.FromHbitmap(intPtr);
img.Save(@"Mypath\test.jpg",System.Drawing.Imaging .ImageFormat.Jpeg);

Have you got any idea?

Best regards,

Wavemill
Nov 17 '05 #1
1 2736
wavemill wrote:
I would like copy my control in a bitmap and after in a jpeg.
I have an error of gdi!
This is my code

System.IntPtr intPtr = this.RichTextBox.Handle;
System.Drawing.Image img = Bitmap.FromHbitmap(intPtr);
img.Save(@"Mypath\test.jpg",System.Drawing.Imagin g.ImageFormat.Jpeg);


That handle returned by the RichTextBox is not a HBitmap, unsurprisingly,
so this doesn't work. The FromHBitmap method works only on handles that
actually belong to a Windows bitmap.

There are two ways of solving your problem, depending on your .NET
version. In .NET 2, there's a new method on the Control, called
DrawToBitmap - this is obviously the easiest thing to use if you're on
..NET 2. In .NET 1, you'll have to reproduce the functionality of that
method yourself. I have recently done that for a blog article - see
http://www.sturmnet.org/blog/archive...-rubber-band2/ ,
right down at the bottom in the comments is the .NET implementation you
need and the sample source code tells you all about using it.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Nov 17 '05 #2

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

Similar topics

1
by: xc | last post by:
Greetings. I encountered a wield problem when grabing screen images. Sometimes in some computers I can capture the screen, but other times not so. In some computer I cannot capture the screen...
3
by: Per | last post by:
Hi all, This may be a newbie question, but I can't find the answer anywhere. I want to make a capture of the screen, or a part of the screen, that contains the main portion of the form. Detecting...
4
by: jxiang | last post by:
I created a child form that is much bigger than the MDI form in VB.Net. I am trying to capture the whole child form and save as an image or sent to printer. I tried to use BitBlt to capture the...
0
by: Berry W | last post by:
Hi, I'm trying to capture hidden window's data that is in IE's AxSHDocVw.AxWebBrowser ActiveX control. If Control and window are visible, code below works but if Control and it's window is...
3
by: aledrjones | last post by:
Hi I've got a c# application that will often run in the background as it is used to monitor connections to a host. An activex control displays the communication between the app and the host. ...
0
by: iMaiden | last post by:
I have a nice little camera that I control via vb.net. It works fine but it has a build in capture feature that is just too slow. Dim snapBuffer(3533600)() As Byte 'raw video data Dim...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
5
Atran
by: Atran | last post by:
Hello Everyone. In this article: You will know to capture the screen in 2 ways: 1)- Capture full screen. 2)- Capture region. Let's Begin: First make a new Windows Application project. And...
2
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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 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.