mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-09 19:29:34 +08:00
Improve code documentation
This commit is contained in:
parent
83052bbc62
commit
195105ee56
@ -1048,7 +1048,7 @@ func (enc *DCTEncoder) EncodeBytes(data []byte) ([]byte, error) {
|
||||
val := uint16(data[i])<<8 | uint16(data[i+1])
|
||||
c = gocolor.Gray16{val}
|
||||
} else {
|
||||
// Account 1-bit/2-bit color images
|
||||
// Account for 1-bit/2-bit color images.
|
||||
val := uint32(data[i]) * 255 / uint32(math.Pow(2, float64(enc.BitsPerComponent))-1)
|
||||
c = gocolor.Gray{uint8(val & 0xff)}
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ func (cs *PdfColorspaceDeviceGray) ImageToRGB(img Image) (Image, error) {
|
||||
|
||||
var rgbSamples []uint32
|
||||
for i := 0; i < len(samples); i++ {
|
||||
// Account 1-bit/2-bit color images
|
||||
// Account for 1-bit/2-bit color images.
|
||||
grayVal := samples[i] * 255 / uint32(math.Pow(2, float64(img.BitsPerComponent))-1)
|
||||
rgbSamples = append(rgbSamples, grayVal, grayVal, grayVal)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func (img *Image) ToGoImage() (goimage.Image, error) {
|
||||
val := uint16(samples[i])<<8 | uint16(samples[i+1])
|
||||
c = gocolor.Gray16{val}
|
||||
} else {
|
||||
// Account 1-bit/2-bit color images
|
||||
// Account for 1-bit/2-bit color images.
|
||||
val := samples[i] * 255 / uint32(math.Pow(2, float64(img.BitsPerComponent))-1)
|
||||
c = gocolor.Gray{uint8(val & 0xff)}
|
||||
}
|
||||
|
@ -51,11 +51,13 @@ func scaleImage(stream *core.PdfObjectStream, scale float64) error {
|
||||
return fmt.Errorf("optimization is not supported for color space %s", xImg.ColorSpace.String())
|
||||
}
|
||||
draw.CatmullRom.Scale(newImage, newImage.Bounds(), goimg, goimg.Bounds(), draw.Over, &draw.Options{})
|
||||
|
||||
i, err = model.ImageHandling.NewImageFromGoImage(newImage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// NewImageFromGoImage always returns a RGBA image.
|
||||
xImg.SetImage(i, model.NewPdfColorspaceDeviceRGB())
|
||||
xImg.ToPdfObject()
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user