473,320 Members | 1,940 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.

creating a mask for a color (uint vs int)

When i try to use a blue mask for a random color like this:

Color.FromArgb( myrand.next() & 0xff0000ff )

I get an error: 0xff0000ff can't be converted to int.

Apparently maximum value for int32 is 7fffffff, so how am I to set the
alpha part to ff ?

May 7 '06 #1
1 3210
>When i try to use a blue mask for a random color like this:

Color.FromArgb( myrand.next() & 0xff0000ff )

I get an error: 0xff0000ff can't be converted to int.


You can cast to int in an unchecked context:

unchecked((int)0xff0000ff)
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 7 '06 #2

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

Similar topics

2
by: Zenon | last post by:
Folks, I am having a problem storing a port number read from a registry and creating a thread, and I cannot figure out why. Here are the relevant details: I have a struct called SOCKET_INFO in...
36
by: Song Yun Zhao | last post by:
Hi, Just wondering what are the dis/advantages of using uint vs int. When would be the best time to use it? Personally I don't use uint that much, but I like to optimize my code and make it...
1
by: Matt Moran | last post by:
Hi, just wondering if anyone out there has created a dialup connection using C# or other dot net language. Is the rasdial.dll the only way to do this? Where can I find code examples to create...
2
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...
2
by: dever | last post by:
I checked my color printers's Printersettings.SupportsColor, which all showed false. What is wrong that I could not use this property. Also, what other way to detect if a printer is color...
7
by: Digital Puer | last post by:
I'd like to be able to create an integer from a range of contiguous bits in another integer. I'm on a big-ending machine, in case that matters. I would ideally like to create a function with this...
31
by: JoeC | last post by:
I have read books and have ideas on how to create objects. I often create my own projects and programs. They end up getting pretty complex and long. I often use objects in my programs they are...
2
by: Ronen Yacov | last post by:
Hi Guys! I've built a test application in VC++ 6.0 which runs on windows XP. It is a just a simple mfc dialog app, which changes the cursor image using cur file. The code is: BOOL...
6
by: AMP | last post by:
Hello, I am trying to do the following with a loop because the amount of channels can change. uint Chan_1 = 0; uint Chan_2 = 0; uint Chan_3 = 0; uint Chan_4 = 0; uint Chan_5 = 0; uint Chan_6...
0
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.