mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 01:27:26 +08:00
feat(图像处理): 修正图像缓存预算
This commit is contained in:
1 parent
dc48962eb3
commit
2573053a82
1 file changed
+6
-2
@@ -42,10 +42,14 @@ func StorageCost(img image.Image, limit int) int {
|
|||||||
}
|
}
|
||||||
cost += cap(encoded.profile)
|
cost += cap(encoded.profile)
|
||||||
if encoded.profile != nil || encoded.pngColor != nil || encoded.config.ColorModel == color.CMYKModel {
|
if encoded.profile != nil || encoded.pngColor != nil || encoded.config.ColorModel == color.CMYKModel {
|
||||||
if w > (limit-cost)/12/h {
|
pixelSize := 12
|
||||||
|
if encoded.config.ColorModel == color.RGBA64Model || encoded.config.ColorModel == color.NRGBA64Model {
|
||||||
|
pixelSize = 16
|
||||||
|
}
|
||||||
|
if w > (limit-cost)/pixelSize/h {
|
||||||
return limit + 1
|
return limit + 1
|
||||||
}
|
}
|
||||||
pixels = w * h * 12
|
pixels = w * h * pixelSize
|
||||||
}
|
}
|
||||||
if result := encoded.result.Load(); result != nil && result.image != nil {
|
if result := encoded.result.Load(); result != nil && result.image != nil {
|
||||||
pixels = max(pixels, StorageCost(result.image, limit-cost))
|
pixels = max(pixels, StorageCost(result.image, limit-cost))
|
||||||
|
|||||||
Reference in new issue
Block a user