handling CMYK jpeg files in Delphi 7

前端 未结 5 1487
北恋
北恋 2021-01-24 01:29

I am trying to access files that are stored as Jpeg files, is there an easy way to display these image files without performance loss ?

5条回答
  •  礼貌的吻别
    2021-01-24 02:20

    Actually, I once modified Jpeg.pas unit to partial CMYK support. Basically after

    jpeg_start_decompress(jc.d) 
    

    you should check

    if jc.d.out_color_space = JCS_CMYK then
    

    and if true following jpeg_read_scanlines will get 4 bytes data instead of 3 bytes.

    Also cinfo.saw_Adobe_marker indicates inverted values (probably Adobe was first who introduced CMYK jpeg variation).

    But the most difficult part is CMYK-RGB conversion. Since there's no universal formula, in best systems it's always table approach. I tried to find some simple approximation, but there's always a picture that does not fit. Just as an example, don't use this formulas as a reference:

     R_:=Max(254 - (111*C +  2*M  +  7*Y  + 36*K) div 128, 0);
     G_:=Max(254 - (30*C  + 87*M  + 15*Y  + 30*K) div 128, 0);
     B_:=Max(254 - (15*C  + 44*M  + 80*Y  + 24*K) div 128, 0);
    

提交回复
热议问题