Recent

Author Topic: JPEG loading color difference FPReadJPEG  (Read 1279 times)

ttomas

  • Full Member
  • ***
  • Posts: 198
Re: JPEG loading color difference FPReadJPEG
« 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;
  3.   ad: TXYZA;
  4. begin
  5.   ad := AXYZA;
  6.   if AReferenceWhite.Illuminant = 'D50' then
  7.   begin
  8.     ad.ChromaticAdapt(AReferenceWhite, ReferenceWhite2D50);
  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
  17.     ad.ChromaticAdapt(AReferenceWhite, ReferenceWhite2D65);
  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
Re: JPEG loading color difference FPReadJPEG
« 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
    • Personal webpage
Re: JPEG loading color difference FPReadJPEG
« 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

ttomas

  • Full Member
  • ***
  • Posts: 198
Re: JPEG loading color difference FPReadJPEG
« Reply #18 on: November 23, 2020, 04:27:59 pm »
Yes without correction just open and save image result is noticeable lot darker.
TAdobeRGBA and XYZAToStdRGBA(AdobeRGBAToXYZA(p^)) visually have same result, little lighter then original. Maybe client will not notice :-).

torumyax

  • New Member
  • *
  • Posts: 34
Re: JPEG loading color difference FPReadJPEG
« Reply #19 on: January 18, 2021, 05:16:45 am »
I'm also interested in this since I developed an image viewer. Recently I noticed a color difference too. When I display a image in a browser or some other windows viewer developed in C#, it looks a lot different. After some googling, I learned about the ICC profile. Any progress? Thank you!

 

TinyPortal © 2005-2018