I'm using BltBit to create an image from a control:
Private Function Getimage(ByVal ctlSource As Control) As Image
Dim gSource As Graphics = ctlSource.CreateGraphics
Dim imgSource As Image = New Bitmap(Me.ClientRectangle.Width,
Me.ClientRectangle.Height, gSource)
Dim gDest As Graphics = Graphics.FromImage(imgSource)
Dim dcSource As IntPtr = gSource.GetHdc
Dim dcDest As IntPtr = gDest.GetHdc
BitBlt(dcDest, 0, 0, ctlSource.ClientRectangle.Width,
ctlSource.ClientRectangle.Height, dcSource, 0, 0, 13369376)
gSource.ReleaseHdc(dcSource)
gDest.ReleaseHdc(dcDest)
Return imgSource
End Function
However, when I'm running my desktop in 16Bit colour mode the image created
does not match the colours of the control. The grey control backgorund gets
copied as a slightly pinky grey. Switching to 32Bit colour mode solves this
problem.
Is there any way I can get round this colour problem and is their any
quicker way to create an image from a control?
--
Cheers,
elziko 4 1061
Hi, http://www.vb-helper.com/howto_net_g...dow_image.html
Ken
--------------
"elziko" <el****@NOTSPAMMINGyahoo.co.uk> wrote in message
news:ug**************@TK2MSFTNGP11.phx.gbl... I'm using BltBit to create an image from a control:
Private Function Getimage(ByVal ctlSource As Control) As Image Dim gSource As Graphics = ctlSource.CreateGraphics Dim imgSource As Image = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height, gSource) Dim gDest As Graphics = Graphics.FromImage(imgSource) Dim dcSource As IntPtr = gSource.GetHdc Dim dcDest As IntPtr = gDest.GetHdc BitBlt(dcDest, 0, 0, ctlSource.ClientRectangle.Width, ctlSource.ClientRectangle.Height, dcSource, 0, 0, 13369376) gSource.ReleaseHdc(dcSource) gDest.ReleaseHdc(dcDest) Return imgSource End Function
However, when I'm running my desktop in 16Bit colour mode the image created does not match the colours of the control. The grey control backgorund gets copied as a slightly pinky grey. Switching to 32Bit colour mode solves this problem.
Is there any way I can get round this colour problem and is their any quicker way to create an image from a control?
--
Cheers,
elziko
* "elziko" <el****@NOTSPAMMINGyahoo.co.uk> scripsit: I'm using BltBit to create an image from a control:
Try this:
<URL:http://www.google.com/groups?selm=sQVN4qGXDHA.2000%40cpmsftngxa06.phx.gb l>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
> Try this:
Thanks, the function in the link you suggested does solve the colour problem
although it is around sixt times slower in my tests!
I think it might me better to look for the source of the colour problem in
my code rather than replacing it... any ideas?
--
Cheers,
elziko This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Altramagnus |
last post by:
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.
When I try to create them, I get "Error creating window handle"
My guess is there is a maximum...
|
by: Jim |
last post by:
I'm a little new to the C# way of doing thisgs... Although
I've done this sort of thing before in VS 6 / MFC...
creatnig controls, ActiveX controls, etc. Creating
controls in MFC is pretty...
|
by: Technical Group |
last post by:
Friends,
Can anybody help me out by sending a piece of C# code showing how to add an
active directory user to a particular user group? If the group does not
exist, then create it.
Thanks in...
|
by: SamIAm |
last post by:
Hi There
I need to create either a user control or custom control to replace my image
controls. I need to be able to dynamically assign a id and file name to the
control before rendering it.
...
|
by: David W. Simmonds |
last post by:
Is there an easy way to create a new browser window from C# and ASP.NET? I
would just like to have a popup window without any menus or toolbars that
would contain a high-res image. The low-res...
|
by: EnglishMan69 |
last post by:
Hello All,
I am using VB2005 Beta 2 in VS 2005 and am running into a small
problem. I need to be able to add a picture box to the main form from
within a thread.
The program goes to a web...
|
by: Dave Keen |
last post by:
Hi
I am a relative newcomer and as usual I am stuck. My ASP.Net 2003 app
has a page which shows data from a database plus an associated picture.
I use an ASP image control sized to 300x300px. ...
|
by: hardieca |
last post by:
Hi,
I would like to create an adapter for the image web control to cure a
pet peeve of mine. Currently, if I write out:
<asp:Image ImageUrl="myPic.jpg" AlternateText="Some text"...
|
by: tshad |
last post by:
oThumbnail.Save is giving me an error:
System.Runtime.InteropServices.ExternalException: A generic error occurred
in GDI+.
theFileName = New FileInfo(strFileName)
fileOut =...
|
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: 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: 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: 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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |