mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 22:29:25 +02:00
fpimage: tiff: fixed writing bits per channel
git-svn-id: trunk@21494 -
This commit is contained in:
parent
95bb7a9129
commit
a5e05d0d65
@ -318,11 +318,35 @@ begin
|
|||||||
if not (IFD.PhotoMetricInterpretation in [0,1,2]) then
|
if not (IFD.PhotoMetricInterpretation in [0,1,2]) then
|
||||||
TiffError('PhotoMetricInterpretation="'+Img.Extra[TiffPhotoMetric]+'" not supported');
|
TiffError('PhotoMetricInterpretation="'+Img.Extra[TiffPhotoMetric]+'" not supported');
|
||||||
|
|
||||||
GrayBits:=StrToIntDef(Img.Extra[TiffGrayBits],8);
|
GrayBits:=0;
|
||||||
RedBits:=StrToIntDef(Img.Extra[TiffRedBits],8);
|
RedBits:=0;
|
||||||
GreenBits:=StrToIntDef(Img.Extra[TiffGreenBits],8);
|
GreenBits:=0;
|
||||||
BlueBits:=StrToIntDef(Img.Extra[TiffBlueBits],8);
|
BlueBits:=0;
|
||||||
|
AlphaBits:=0;
|
||||||
|
case IFD.PhotoMetricInterpretation of
|
||||||
|
0,1:
|
||||||
|
begin
|
||||||
|
GrayBits:=StrToIntDef(Img.Extra[TiffGrayBits],8);
|
||||||
|
BitsPerSample[0]:=GrayBits;
|
||||||
|
SamplesPerPixel:=1;
|
||||||
|
end;
|
||||||
|
2:
|
||||||
|
begin
|
||||||
|
RedBits:=StrToIntDef(Img.Extra[TiffRedBits],8);
|
||||||
|
GreenBits:=StrToIntDef(Img.Extra[TiffGreenBits],8);
|
||||||
|
BlueBits:=StrToIntDef(Img.Extra[TiffBlueBits],8);
|
||||||
|
BitsPerSample[0]:=RedBits;
|
||||||
|
BitsPerSample[1]:=GreenBits;
|
||||||
|
BitsPerSample[2]:=BlueBits;
|
||||||
|
SamplesPerPixel:=3;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
AlphaBits:=StrToIntDef(Img.Extra[TiffAlphaBits],8);
|
AlphaBits:=StrToIntDef(Img.Extra[TiffAlphaBits],8);
|
||||||
|
if AlphaBits>0 then begin
|
||||||
|
BitsPerSample[SamplesPerPixel]:=AlphaBits;
|
||||||
|
inc(SamplesPerPixel);
|
||||||
|
end;
|
||||||
|
|
||||||
ImgWidth:=Img.Width;
|
ImgWidth:=Img.Width;
|
||||||
ImgHeight:=Img.Height;
|
ImgHeight:=Img.Height;
|
||||||
Compression:=1;
|
Compression:=1;
|
||||||
@ -357,23 +381,7 @@ begin
|
|||||||
AddEntryShort(296,IFD.ResolutionUnit);
|
AddEntryShort(296,IFD.ResolutionUnit);
|
||||||
AddEntryRational(282,IFD.XResolution);
|
AddEntryRational(282,IFD.XResolution);
|
||||||
AddEntryRational(283,IFD.YResolution);
|
AddEntryRational(283,IFD.YResolution);
|
||||||
case IFD.PhotoMetricInterpretation of
|
|
||||||
0,1:
|
|
||||||
begin
|
|
||||||
BitsPerSample[0]:=GrayBits;
|
|
||||||
SamplesPerPixel:=1;
|
|
||||||
end;
|
|
||||||
2:
|
|
||||||
begin
|
|
||||||
BitsPerSample[0]:=RedBits;
|
|
||||||
BitsPerSample[1]:=GreenBits;
|
|
||||||
BitsPerSample[2]:=BlueBits;
|
|
||||||
SamplesPerPixel:=3;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if AlphaBits>0 then begin
|
if AlphaBits>0 then begin
|
||||||
BitsPerSample[SamplesPerPixel]:=AlphaBits;
|
|
||||||
inc(SamplesPerPixel);
|
|
||||||
// ExtraSamples
|
// ExtraSamples
|
||||||
AddEntryShort(338,2);// 2=unassociated alpha
|
AddEntryShort(338,2);// 2=unassociated alpha
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user