mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 13:56:32 +08:00
1 parent
75b6943e10
commit
3d54b15b11
2 files changed
+26
-4
No files matched your search
@@ -658,12 +658,27 @@ func (c *pdfCompositor) mask(mask *pdfgo.SoftMask, inherited *pdfgo.ColorSpace)
|
||||
c.scratch.masks.release(result)
|
||||
}
|
||||
}()
|
||||
values := make(map[[4]float64]float64)
|
||||
var previous [4]float64
|
||||
var opacity float64
|
||||
for i, pixel := range pixels {
|
||||
if i%pdfCompositeTileSize == 0 {
|
||||
if err := c.importer.ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
key := [4]float64{pixel.Alpha}
|
||||
if mask.Subtype == "Luminosity" {
|
||||
key = pixel.Values
|
||||
}
|
||||
if i != 0 && key == previous {
|
||||
result[i] = opacity
|
||||
continue
|
||||
}
|
||||
if cached, ok := values[key]; ok {
|
||||
previous, opacity, result[i] = key, cached, cached
|
||||
continue
|
||||
}
|
||||
v := pixel.Alpha
|
||||
if mask.Subtype == "Luminosity" {
|
||||
v, err = space.Luminosity(pixel.Values[:space.Components()], "RelativeColorimetric")
|
||||
@@ -675,6 +690,10 @@ func (c *pdfCompositor) mask(mask *pdfgo.SoftMask, inherited *pdfgo.ColorSpace)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
previous, opacity = key, result[i]
|
||||
if len(values) < 2*pdfCompositeTileSize {
|
||||
values[key] = opacity
|
||||
}
|
||||
}
|
||||
complete = true
|
||||
c.masks[mask] = result
|
||||
|
||||
Reference in new issue
Block a user