Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced
Yaniv 11 15368
More details about my problem:
I want to change the color of label (Label1.ForeCol or which is
system.drawing. color).
I want to take the color from object which has a Uint32 color
Yaniv כתב:
Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced
Yaniv
More details about my problem:
I want to change the color of label (Label1.ForeCol or which is
system.drawing. color).
I want to take the color from object which has a Uint32 color
Yaniv כתב:
Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced
Yaniv
Yaniv wrote:
Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced
Yaniv
If the integer is representing an argb (alpha+rgb) value, then you can
use the Color.FromArgb( int) method. If it only represents an rgb value,
then you can use Color.FromArgb( int, int), where the first integer is
the alpha value, which you should set to 255 to get a solid color.
--
Göran Andersson
_____ http://www.guffa.com
Göran Andersson כתב:
Yaniv wrote:
Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced
Yaniv
If the integer is representing an argb (alpha+rgb) value, then you can
use the Color.FromArgb( int) method. If it only represents an rgb value,
then you can use Color.FromArgb( int, int), where the first integer is
the alpha value, which you should set to 255 to get a solid color.
--
Göran Andersson
_____ http://www.guffa.com
Hi
The first option you wrote is not working since the value is Uint32
and not integer as you wrote (I'v got the message "Value of type
'System.UInt32' cannot be converted to 'Integer')
The second option doesn't exist in VB.NET at all (Anyway I can't
convert Uint32 to int.....)
actually I dont know if the Uint32 color is represent argb color or
only rgb color...
Yaniv wrote:
Göran Andersson כתב:
>Yaniv wrote:
>>Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced Yaniv
If the integer is representing an argb (alpha+rgb) value, then you can use the Color.FromArgb( int) method. If it only represents an rgb value, then you can use Color.FromArgb( int, int), where the first integer is the alpha value, which you should set to 255 to get a solid color.
-- Göran Andersson _____ http://www.guffa.com
Hi
The first option you wrote is not working since the value is Uint32
and not integer as you wrote (I'v got the message "Value of type
'System.UInt32' cannot be converted to 'Integer')
You can just cast the UInt32 to an Int32:
Color color = Color.FromArgb( (int)colorValue );
The second option doesn't exist in VB.NET at all (Anyway I can't
convert Uint32 to int.....)
Yes, you are right. There is no such overload to the method. I was
thinking of the Color.FromArgb( int, Color) overload:
Color color = Color.FromArgb( 255, Color.FromArgb( (int)colorValue ));
actually I dont know if the Uint32 color is represent argb color or
only rgb color...
That will be obvious when you try to use it. If it's an rgb value the
top eight bits will be zero, which when used as alpha will make a
completely transparent color.
--
Göran Andersson
_____ http://www.guffa.com
Göran Andersson wrote:
Yaniv wrote:
>Göran Andersson כתב:
>>Yaniv wrote: Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced Yaniv
If the integer is representing an argb (alpha+rgb) value, then you can use the Color.FromArgb( int) method. If it only represents an rgb value, then you can use Color.FromArgb( int, int), where the first integer is the alpha value, which you should set to 255 to get a solid color.
-- Göran Andersson _____ http://www.guffa.com Hi
The first option you wrote is not working since the value is Uint32 and not integer as you wrote (I'v got the message "Value of type 'System.UInt32 ' cannot be converted to 'Integer')
You can just cast the UInt32 to an Int32:
Color color = Color.FromArgb( (int)colorValue );
Sorry, I gave you C# examples.
In VB.NET:
Dim color As Color = Color.FromArgb( CType(colorValu e, Int32))
>The second option doesn't exist in VB.NET at all (Anyway I can't convert Uint32 to int.....)
Yes, you are right. There is no such overload to the method. I was
thinking of the Color.FromArgb( int, Color) overload:
Color color = Color.FromArgb( 255, Color.FromArgb( (int)colorValue ));
Dim color As Color = Color.FromArgb( 255,
Color.FromArgb( CType(colorValu e, Int32)))
>actually I dont know if the Uint32 color is represent argb color or only rgb color...
That will be obvious when you try to use it. If it's an rgb value the
top eight bits will be zero, which when used as alpha will make a
completely transparent color.
--
Göran Andersson
_____ http://www.guffa.com
"Yaniv" <el******@gmail .comschrieb
Hi
How can I convert Uint32 variable to System.drawing. color ??
Thanks in advanced
Yaniv
Dim u As UInt32 = &HFFFFFFFFUI
Dim c As Color
c = Color.FromArgb( _
BitConverter.To Int32(BitConver ter.GetBytes(u) , 0) _
)
Armin
"Göran Andersson" <gu***@guffa.co mschrieb
>You can just cast the UInt32 to an Int32:
Color color = Color.FromArgb( (int)colorValue );
Sorry, I gave you C# examples.
In VB.NET:
Dim color As Color = Color.FromArgb( CType(colorValu e, Int32))
This doesn't work if colorvalue>int3 2.maxvalue, which is usually the case if
the alpha value 127.
Armin
Armin Zingler wrote:
"Göran Andersson" <gu***@guffa.co mschrieb
>>You can just cast the UInt32 to an Int32:
Color color = Color.FromArgb( (int)colorValue );
Sorry, I gave you C# examples.
In VB.NET:
Dim color As Color = Color.FromArgb( CType(colorValu e, Int32))
This doesn't work if colorvalue>int3 2.maxvalue, which is usually the
case if the alpha value 127.
Yes, you are right. I tried this in VB, and it won't convert an UInt32
to an Int32 without checking for overflow. It works just fine in C#.
Some say that the CType function in VB is the same as casting in C#, but
obviously it isn't.
I also tried CInt, Convert.ToInt32 and DirectCast, but they all do
overflow checking.
I guess you have to chop up the value in pieces to handle it:
Dim alpha As Integer = colorCode >24
Dim code As Integer = colorCode And &HFFFFFF
Dim c As Color = Color.FromArgb( alpha, Color.FromArgb( code))
or:
Dim alpha As Integer = colorCode >24
Dim red As Integer = (colorCode >16) And &HFF
Dim green As Integer = (colorCode >8) And &HFF
Dim blue As Integer = colorCode And &HFF
Dim c As Color = Color.FromArgb( alpha, red, green, blue)
--
Göran Andersson
_____ http://www.guffa.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Toby Mathews |
last post by:
Hi,
In an ASP.Net application I want to convert open create a FileStream
object from a System.Drawing.Image - is this possible? I create an instance
of an Image object using the FromFile method, then use the GetThumbnailImage
method to create a second Image. This second one is the one I want to get a
FileStream from, so that I can then use its Handle to use Response.WriteFile
to output the thumbnail on my ASP.Net page.
Any help would...
|
by: Nicolas Guilhot |
last post by:
Hi all !
I have a multi-page Tiff image file that I want to convert to PDF. To do so
I am using iText library. The conversion is working, but the code execution
is very different according to wich
iTextSharp.text.Image.getInstance(...) signature I am using :
- using code 1 below, the conversion is fast enough but the resulting PDF
file is too big (1 817ko sample Tiff file is converted in less than 30
seconds to a 2 764ko PDF file)
-...
|
by: Altramagnus |
last post by:
I have a complicated Region object, which I need to draw the outline, but
not fill
How can I convert the Region object to GraphicsPath object?
or How can I draw the outline of the Region object?
|
by: Fritz Switzer |
last post by:
With two controls a PictureBox and another "PictureBox like" , Pic2, a
control from a dll, I'm stuck on cannot implicity convert
System.Drawing.Image to System.Drawing.Bitmap error.
How do I convert the following code so that the Pic2 can accept the Image
from the stream where it wants Picture property not and Image property.
Here is a snippet, I'm trying to avoid writing to disk.:
Image i = Pic1.Image;
|
by: John |
last post by:
I want to convert the value of color.RGB of font object to hexadecimal
value.
How is it possible. Can some one help me.
I want to do it through my code internally without using any third party
tool.
John
| |
by: Scott Schluer |
last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG)
to a B&W photo?
Thanks,
Scott
|
by: Russ Green |
last post by:
I'm currentlyworking on a VB.NET application to control Sketchup
(http://www.sketchup.com) using COM.
Sketchup has a color class with color.red, color.green and color.blue but
this is not appearing in the Interop layer. Instead, RGB colours are of
type System.Uint32.
I need a method to converty a UInt32 to RGB values. Can anyone point me in
the right direction?
|
by: Sugan |
last post by:
Hi all,
I'm creating a custom button control. I need to show a color image when
the button control is enabled and a gray shade of the same image when
the button control is disabled. How can i convert a color image to a
gray image in VB 2005.
Thanks,
Sugan
Chennai, INDIA
|
by: Jonathan Wood |
last post by:
Does anyone know why the toBase argument in Convert.ToString() is limited to
2, 8, 10, or 16? It takes virtually the same code to support all base values
from 2 to 36.
And can anyone tell me if the .NET library provides the means to convert a
number to a string using base-36?
Thanks.
--
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |