update to latest
This commit is contained in:
@@ -91,7 +91,8 @@ func toMonochrome(img image.Image) *image.Gray {
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
|
||||
for x := bounds.Min.X; x < bounds.Max.X; x++ {
|
||||
r, g, b, _ := img.At(x, y).RGBA()
|
||||
grayValue := uint8((r + g + b) / 3 >> 8)
|
||||
// grayValue := uint8((r + g + b) / 3 >> 8)
|
||||
grayValue := uint8((0.299*float64(r) + 0.587*float64(g) + 0.114*float64(b)) / 256.0)
|
||||
if grayValue > 128 {
|
||||
gray.Set(x, y, color.White)
|
||||
} else {
|
||||
@@ -138,7 +139,6 @@ func escposRaster(img *image.Gray) []byte {
|
||||
data = append(data, b)
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user