AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia FreePascal RGB/CMK/CMYK conversions
Thema durchsuchen
Ansicht
Themen-Optionen

RGB/CMK/CMYK conversions

Ein Thema von WojTec · begonnen am 2. Jan 2012 · letzter Beitrag vom 19. Jan 2012
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 14:01
Delphi-Quellcode:
procedure _CMYToCMYK(const C, M, Y: Single; out Cyan, Magenta, Yellow, Black: Single);
var
  var_K: Single;
begin
  var_K := 1;

  if C < var_K then var_K := C;
  if M < var_K then var_K := M;
  if Y < var_K then var_K := Y;

  if var_K = 1 then
  begin //Black
     Cyan := 0;
     Magenta := 0;
     Yellow := 0;
  end
  else
  begin
     Cyan := (C - var_K) / (1 - var_K);
     Magenta := (M - var_K) / (1 - var_K);
     Yellow := (Y - var_K) / (1 - var_K);
  end;

  Black := var_K;
end;

procedure _CMYKToCMY(const C, M, Y, K: Single; out Cyan, Magenta, Yellow: Single);
begin
  Cyan := (C * (1 - K) + K);
  Magenta := (M * (1 - K) + K);
  Yellow := (Y * (1 - K) + K);
end;

procedure _RGBToCMY(const R, G, B: Byte; out C, M, Y: Single);
begin
  C := 1 - (R / 255);
  M := 1 - (G / 255);
  Y := 1 - (B / 255);
end;

procedure _CMYToRGB(const C, M, Y: Single; out R, G, B: Byte);
begin
  R := Round((1 - C) * 255);
  G := Round((1 - M) * 255);
  B := Round((1 - Y) * 255);
end;

procedure _RGBToCMYK(const R, G, B: Byte; out C, M, Y, K: Single);
var
  Cyan, Magenta, Yellow: Single;
begin
  _RGBToCMY(R, G, B, Cyan, Magenta, Yellow);
  _CMYToCMYK(Cyan, Magenta, Yellow, C, M, Y, K)
end;

procedure _CMYKToRGB(const C, M, Y, K: Single; out R, G, B: Byte);
var
  Cyan, Magenta, Yellow: Single;
begin
  _CMYKToCMY(C, M, Y, K, Cyan, Magenta, Yellow);
  _CMYToRGB(Cyan, Magenta, Yellow, R, G, B);
end;
Formulas I got from EasyRGB. Result are different in this code and Photoshop:

Code:
_CMYKToRGB(0.11, 0.13, 0.99, 0, R, G, B); // 227 222 3; ps: 232, 207, 30
_CMYKToRGB(0, 0, 0.5, 0.5, R, G, B); // 124 124 64; ps: 150 145 91
Where is bug?
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.140 Beiträge
 
Delphi 12 Athens
 
#2

AW: RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 14:16
Where is bug?
Total falsche Formeln?

Zitat:
Delphi-Quellcode:
procedure _RGBToCMY(const R, G, B: Byte; out C, M, Y: Single);
begin
  C := 1 - (R / 255);
  M := 1 - (G / 255);
  Y := 1 - (B / 255);
end;

procedure _CMYToRGB(const C, M, Y: Single; out R, G, B: Byte);
begin
  R := Round((1 - C) * 255);
  G := Round((1 - M) * 255);
  B := Round((1 - Y) * 255);
end;
Cyan <=> Red
Mngenta <=> Green
Yellow <=> Blue

Aber eigentlich ist es so:

Cyan <=> Blue und Green
Mangenta <=> Blue und Red
Yellow <=> Red und Green
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 14:39
Hm, what is valid formula? I saw on the Internet only this one.
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 17:44
Except from the rounding mismatches in ur formula Online Color Conversion

did u switch off the Color Management in PS?
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 18:29
@Sir Rufo, what is wrong in this code, please tell me

I set color management policies to off, when was off the same as now.
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#6

AW: RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 19:47
try Extended instead of Single
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#7

Re: RGB/CMK/CMYK conversions

  Alt 2. Jan 2012, 20:19
Could you please explain me why? Why is required extended precision?
  Mit Zitat antworten Zitat
jus

Registriert seit: 22. Jan 2005
343 Beiträge
 
Delphi 2007 Professional
 
#8

AW: RGB/CMK/CMYK conversions

  Alt 11. Jan 2012, 15:31
Hi WojTec,

have you already found a solution for this?

jus
  Mit Zitat antworten Zitat
DonAlfredo

Registriert seit: 13. Mai 2010
19 Beiträge
 
#9

AW: RGB/CMK/CMYK conversions

  Alt 16. Jan 2012, 14:57
This could help !

http://www.koders.com/delphi/fid212A...FBC.aspx?s=ftp

Keyword: RealColorLibrary

Greetings, Alfred.
Alfred
  Mit Zitat antworten Zitat
jus

Registriert seit: 22. Jan 2005
343 Beiträge
 
Delphi 2007 Professional
 
#10

AW: RGB/CMK/CMYK conversions

  Alt 19. Jan 2012, 12:54
The formulas in the link from donalfredo seems to be very similiar to Wojtec. I did some research for myself. I get also very similiar results from photoshop as wojtec depending on which profiles i set. I think the differences come from the adobe colormanagement engine. So the photoshop does a full color space conversion between icc profiles and such approximation formulas like "C:=1-(R/255)..." don't work any more.


jus

Geändert von jus (19. Jan 2012 um 13:32 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:05 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz