Les couleurs primaires des tubes des pots de peinture.

Contenu du snippet

Deux modèles colorimétriques existent,
la synthése additive des écrans en Rouge,vert bleu,
quand on les additionne on obtient du blanc,
la synthèse soustrative des couleurs des imprimeurs
soit le Cyan, la magenta et le jaune,
cette algorithme permer de convertir
une couleur composée de rouge, vert et de bleu en cyan, magenta jaune et noir.
Comme quand on mélange ces coleurs on obtient du gris souris (comme avec la pâte à modeler),
les imprimeurs ajoutent un film de noir, voici ces équations :


unit Cyan_magenta_jaune_et_noir;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

procedure RGB_to_CMYB(RGB_long:TcolorRef; VAR Real_Cyan,Real_Magenta,Real_Yellow,Real_black:real)
procedure CMYB_to_RGB(Real_Cyan,Real_Magenta,Real_Yellow,Real_black:real; var RGB_long:TcolorRef);
function Obtenir_le_vrai_CMYN(une_color:tcolorref):string;


implementation

{$R *.dfm}

function Real_min(a,b:Real):Real;
 begin 
 if a<b then
  Real_min:=a 
 else 
  Real_min:=b; 
 end;
 
function Real_max(a,b:Real):Real;
 begin 
 if a>b then 
  Real_max:=a 
 else 
  Real_max:=b; 
 end;


procedure RGB_to_CMYB(RGB_long:TcolorRef; VAR Real_Cyan,Real_Magenta,Real_Yellow,Real_black:real);
 var rouge,vert,bleu:real;
 begin
 rouge:=GetRvalue(RGB_long);
 vert:=GetGvalue(RGB_long);
 bleu:=GetBvalue(RGB_long);
 Real_Cyan:=1.0-(rouge/255);
 Real_Magenta:=1.0-(vert/255);
 Real_Yellow:=1.0-(bleu/255);
 Real_black:=Real_min(Real_min(Real_Cyan,Real_Magenta),Real_Yellow);
 Real_Cyan:=Real_Cyan-Real_black;
 Real_Magenta:=Real_Magenta-Real_black;
 Real_Yellow:=Real_Yellow-Real_black;
 end; {RGB_to_CMYB}

procedure CMYB_to_RGB(Real_Cyan,Real_Magenta,Real_Yellow,Real_black:real; var RGB_long:TcolorRef);
 begin
 Real_Cyan:=Real_min(1.0,Real_Cyan+Real_black);
 Real_Magenta:=Real_min(1.0,Real_Magenta+Real_black);
 Real_Yellow:=Real_min(1.0,Real_Yellow+Real_black);

 RGB_long:=rgb(
  round((1.0-Real_Cyan)*255),
  round((1.0-Real_Magenta)*255),
  round((1.0-Real_Yellow)*255));
 end; {CMYB_to_RGB}

function Obtenir_valeurs_Cyan_magenta_jaune_et_noir(une_couleur:tcolorref):string;
  var Real_Cyan,Real_Magenta,Real_Yellow,Real_black:real;
  begin
  RGB_to_CMYB(une_couleur,Real_Cyan,Real_Magenta,Real_Yellow,Real_black);
  Obtenir_valeurs_Cyan_magenta_jaune_et_noir:=
      'Cyan='+floattostrF(Real_Cyan*100,fffixed,4,1)+'% '+
      'Magenta='+floattostrF(Real_Magenta*100,fffixed,4,1)+'%'+
      'Jaune='+floattostrF(Real_Yellow*100,fffixed,4,1)+'% '+
      'Noir='+floattostrF(Real_black*100,fffixed,4,1)+'%';
   end; {Afficher_les_valeurs_Cyan_magenta_jaune_et_noi}

{La chaîne résultante permet, d'obtenir une somme de pourcentage égal à 100%}
function Obtenir_le_vrai_CMYN(une_color:tcolorref):string;
  var somme:real;
      Real_Cyan,Real_Magenta,Real_Yellow,Real_black:real;
      lst_cyan_magenta_jaune_et_noir:string;
  begin
  RGB_to_CMYB(une_color,Real_Cyan,Real_Magenta,Real_Yellow,Real_black);
  Somme:=Real_Cyan+Real_Magenta+Real_Yellow+Real_black;
    lst_cyan_magenta_jaune_et_noir:=
      'Cyan='+inttostr(round((Real_Cyan/somme)*100))+'% '+
      'Magenta='+inttostr(round((Real_Magenta/somme)*100))+'% '+
      'Jaune='+inttostr(round((Real_Yellow/somme)*100))+'% '+
      'Noir='+inttostr(round((Real_black/somme)*100))+'%';
  Obtenir_le_vrai_CMYN:=lst_cyan_magenta_jaune_et_noir;
  end;


Compatibilité : 1.1

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.