### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Recent

#### ttomas

• Full Member
• Posts: 198
« Reply #15 on: November 23, 2020, 09:52:52 am »
@circular Yes i play with AdobeRGBAToXYZA. Is StdRGB same as sRGB? I think we need AdobeRGBA -> XYZA -> sRGB transformation.
In extendedcolorspaces.inc is missing function XYZAToStdRGBA. I copy code from XYZAToAdobeRGBA to XYZAToStdRGBA and change matrix for sRGB from
http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
Then try p^ := XYZAToStdRGBA(AdobeRGBAToXYZA(p^)).ToBGRAPixel;
Result is corrupted image, need some help.
Code: Pascal  [Select][+][-]
1. function XYZAToStdRGBA(const AXYZA: TXYZA; const AReferenceWhite: TXYZReferenceWhite): TStdRGBA;
2. var R,G,B: single;
4. begin
5.   ad := AXYZA;
6.   if AReferenceWhite.Illuminant = 'D50' then
7.   begin
9.     with ad do
10.     begin
11.       R := Clamp(3.1338561*X - 1.6168667*Y - 0.4906146*Z,0,1);
12.       G := Clamp(-0.9787684*X + 1.9161415*Y + 0.0334540*Z,0,1);
13.       B := Clamp(0.0719453*X - 0.2289914*Y + 1.4052427*Z,0,1);
14.     end;
15.   end else
16.   begin
18.     with ad do
19.     begin
20.       R := Clamp(3.2404542*X - 1.5371385*Y - 0.4985314*Z,0,1);
21.       G := Clamp(-0.9692660*X + 1.8760108*Y + 0.0415560*Z,0,1);
22.       B := Clamp(0.0556434*X - 0.2040259*Y + 1.0572252*Z,0,1);
23.     end;
24.   end;
25.   result.red := GammaCompressionTab[round(R*65535)];
26.   result.green := GammaCompressionTab[round(G*65535)];
27.   result.blue := GammaCompressionTab[round(B*65535)];
28.   result.alpha := ClampInt(round(AXYZA.alpha*255),0,255);
29. end;
« Last Edit: November 23, 2020, 09:56:38 am by ttomas »

#### ttomas

• Full Member
• Posts: 198
« Reply #16 on: November 23, 2020, 10:51:05 am »
I change result to
Code: Pascal  [Select][+][-]
1.   result.red := R;
2.   result.green := G;
3.   result.blue := B;
4.
Now I have correct image, but colors are same as using TAdobeRGBA.New(p^.red, p^.green, p^.blue);

#### circular

• Hero Member
• Posts: 3645
« Reply #17 on: November 23, 2020, 02:35:11 pm »
Yes StdRGB stands for sRGB (s means standard).

Ok so you find the same result.
Conscience is the debugger of the mind

• Full Member
• Posts: 198