mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 01:27:26 +08:00
perf(色彩管理): 优化四色图像显示性能
This commit is contained in:
1 parent
b5a8c9af9c
commit
e1bf215e6a
1 file changed
+10
-3
@@ -260,9 +260,6 @@ func jpegDisplayImage(ctx context.Context, source image.Image, profile *pdfgo.Co
|
|||||||
}
|
}
|
||||||
return source, nil
|
return source, nil
|
||||||
}
|
}
|
||||||
if profile == nil {
|
|
||||||
profile = &pdfgo.ColorSpace{Model: "DeviceCMYK"}
|
|
||||||
}
|
|
||||||
bounds := cmyk.Bounds()
|
bounds := cmyk.Bounds()
|
||||||
if bounds.Dx() <= 0 || bounds.Dy() <= 0 || bounds.Dx() > math.MaxInt/8/bounds.Dy() {
|
if bounds.Dx() <= 0 || bounds.Dy() <= 0 || bounds.Dx() > math.MaxInt/8/bounds.Dy() {
|
||||||
return nil, fmt.Errorf("JPEG color image dimensions exceed capacity")
|
return nil, fmt.Errorf("JPEG color image dimensions exceed capacity")
|
||||||
@@ -276,6 +273,16 @@ func jpegDisplayImage(ctx context.Context, source image.Image, profile *pdfgo.Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ink := cmyk.CMYKAt(x, y)
|
ink := cmyk.CMYKAt(x, y)
|
||||||
|
if profile == nil {
|
||||||
|
white := 255 - int(ink.K)
|
||||||
|
pixels.SetNRGBA64(x, y, color.NRGBA64{
|
||||||
|
R: uint16(max(0, white-int(ink.C))) * 257,
|
||||||
|
G: uint16(max(0, white-int(ink.M))) * 257,
|
||||||
|
B: uint16(max(0, white-int(ink.Y))) * 257,
|
||||||
|
A: 65535,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
values := [4]float64{float64(ink.C) / 255, float64(ink.M) / 255, float64(ink.Y) / 255, float64(ink.K) / 255}
|
values := [4]float64{float64(ink.C) / 255, float64(ink.M) / 255, float64(ink.Y) / 255, float64(ink.K) / 255}
|
||||||
rgb, err := profile.SRGB(values[:], profile.DefaultIntent())
|
rgb, err := profile.SRGB(values[:], profile.DefaultIntent())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user