Answer Posted / Mr Praveen Kumar Jain
Converting an RGB color to CMYK in Delphi can be done using the following formula:nn```delphinfunction RGBToCMYK(r, g, b: Byte): TColor;nvarn c, m, y, k: Double;nbeginn r := r / 255; g := g / 255; b := b / 255;nn // Find minimum valuen if (r < g) and (r < b) thenn c := r;n else if g < b thenn c := g;n elsen c := b;nn // Calculate remaining valuesn m := (r - c) / (1 - c);n y := (g - c) / (1 - c);n k := (b - c) / (1 - c);nn // Convert CMYK values to TColor and returnn Result := RGBToCMYK_TColor(c, m, y, k);nend;nnfunction RGBToCMYK_TColor(c, m, y, k: Double): TColor;nbeginn // Adjust CMYK values to fit within range (0-255)n c := Round(c * 255); m := Round(m * 255); y := Round(y * 255); k := Round(k * 255);nn // Create a TColor with CMYK values and returnn Result := TColor.CMYKToRGB(c, m, y, k);nend;n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to Determine the last access time of a given file ?
How can one prevent a TForm from being moved or resized?
How to Create resource files?
How to Print in Delphi without using the TPrinter Unit ?
How to Get the time and date in Universal Time ?
How to Retrieving the program that is associated with a given extension?
How to Remove drives listed in a TDriveComboBox ?
How to Change the owner of a component at runtime ?
How to Flush binary file from disk cache to disk ?
How to Retrieve the line number that a memo's cursor is on?
How to Save a QuickReport custom preview to text?
How to Change the default width/height of the editor?