Convert UNICODE to RGB color in C# -


I want to write code to write in C # which converts every Unicode code to RGB color value. I use UTF-16, this table has three columns for four or one mark or number, the second column of its unicode code and the last column of one of 16 million colors, one can recommend an easy way to do this ???

If you ignore the combination of letters, then each unicode code point is 16 bits. RGB is a 24-bit space that uses a byte for red, one byte for green and one byte for blue. Obviously if you can not do this with 16-bit code, what do you do, for example 5 bits for red, 5 bits for green, and 6 bits for blue is one way to do this.

Say you have given a string:

  const string foo = "hello, world."; // rrrr rggg gggbbbbb console int redmask = 0xF8; const int greenmask = 0xF8; const int BlueMask = 0xFC; Const int RedShift = 8; Const int GreenShift = 3; const int BlueShift = 2; Forrest (Veer Si Fu) {int val = c; Int R = (Well & G; RedShift) & amp; RedMask; Int g = (val> gt; & gt; GreenShift) & amp; GreenMask; Int b = (well & lt;; bluetooth) & amp; BlueMask; // Now make a color color CLR = color. RARBB (RG, B); // and do something with it}   

This code uses high 5 bits (6 bits for blue) for each color, which means that you use less bits Will give a little more variation.

Anything forces you to use 5,5,6 as I did. You can make it 5,6,5 or 6,5,5, or 3,8,5, or whatever combination r / g / b You want to change only the changes and offsets.

He said, for typical English lessons, the colors will be very similar. You can do other interesting things, though they will do some more work. For example, you can create a blue component in the form of a combination of 0, 3, 6, 9, 12 and 15. Green will be bitten in 1, 4, 7, 10 and 13. Red bits 2, 5, 8, 11, and 14. It can distinguish those characters that are very close together.

This idea is the same: Choose specific bits from the Unicode value and the elements of red, green, and blue color.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -