Color (color) to three colors (r/g/B) (Dry Goods sharing), color dry goods

Source: Internet
Author: User

Color (color) to three colors (r/g/B) (Dry Goods sharing), color dry goods
// Color conversion #665522-three-color value
+ (UIColor *) setFontColorWithString :( NSString *) color
{
NSString * cString = [color stringByTrimmingCharactersInSet: [NSCharacterSetwhitespaceAndNewlineCharacterSet] uppercaseString];

// The number of strings must be greater than or equal to 6
If ([cString length] <6 ){
Return [UIColorclearColor];
}

// Differentiate Based on hexadecimal notation
If ([cString hasPrefix: @ "0X"])
CString = [cString substringFromIndex: 2];
If ([cString hasPrefix: @ "#"])
CString = [cString substringFromIndex: 1];
If ([cString length]! = 6)
Return [UIColorclearColor];

// It can be divided into r, g, and B Sub-strings.
Nsange range;
Range. location = 0;
Range. length = 2;

// R
NSString * rString = [cString substringWithRange: range];

// G
Range. location = 2;
NSString * gString = [cString substringWithRange: range];

// B
Range. location = 4;
NSString * bString = [cString substringWithRange: range];

// Scan r, g, and B Values
Unsignedint r, g, B;
[[NSScannerscannerWithString: rString] scanHexInt: & r];
[[NSScannerscannerWithString: gString] scanHexInt: & g];
[[NSScannerscannerWithString: bString] scanHexInt: & B];

Return RgbHex2UIColor (r, g, B );
}
The RGB color value is converted to a hexadecimal color value. Please write down the R, G, and B conversion process.

I don't know what language you are using. A brother has already provided an algorithm. Let me add another VBS algorithm.
Function rgb2hex (r, g, B)
Rgb2hex = "#" & Right ("0" & Hex (r), 2) & Right ("0" & Hex (g), 2) & Right ("0" & Hex (B), 2)
End Function
The idea is very simple. Convert the three colors of red, green, and blue into hexadecimal values respectively. If there are less than two prefixes, 0 is filled, and then strings are connected in the red, green, and blue order, that is, the hexadecimal color value, if it is used in HTML or CSS, It is prefixed #.

What if the printer is partial?

Large printer Color Deviation
First, print the color block to test the ink effect, and then compare it with the color sample to see if it is the reason for ink.
Second: There is a Nozzle Calibration in the printer, and the model nozzle correction color is sold in. After repeated debugging, the color should be correct.
Third: you can find the cause of chromatic aberration in the drawing software.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.