From e1bf215e6afea12604dfb935725a35ba1c68926e Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Fri, 16 Oct 2026 00:12:48 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E8=89=B2=E5=BD=A9=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=9B=E8=89=B2=E5=9B=BE=E5=83=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/base/image/color.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/base/image/color.go b/internal/base/image/color.go index b61159a..6bc3869 100644 --- a/internal/base/image/color.go +++ b/internal/base/image/color.go @@ -260,9 +260,6 @@ func jpegDisplayImage(ctx context.Context, source image.Image, profile *pdfgo.Co } return source, nil } - if profile == nil { - profile = &pdfgo.ColorSpace{Model: "DeviceCMYK"} - } bounds := cmyk.Bounds() if bounds.Dx() <= 0 || bounds.Dy() <= 0 || bounds.Dx() > math.MaxInt/8/bounds.Dy() { 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) + 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} rgb, err := profile.SRGB(values[:], profile.DefaultIntent()) if err != nil {