Commit 622db71 wangbei
committed
1 parent bcdd5e3 commit 622db71 Copy full SHA for 622db71
File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -293,11 +293,11 @@ func (q *QRCode) Image(size int) image.Image {
293
293
// Saves a few bytes to have them in this order
294
294
p := color .Palette ([]color.Color {q .BackgroundColor , q .ForegroundColor })
295
295
img := image .NewPaletted (rect , p )
296
+ bgClr := uint8 (img .Palette .Index (q .BackgroundColor ))
297
+ fgClr := uint8 (img .Palette .Index (q .ForegroundColor ))
296
298
297
- for i := 0 ; i < size ; i ++ {
298
- for j := 0 ; j < size ; j ++ {
299
- img .Set (i , j , q .BackgroundColor )
300
- }
299
+ for i := range img .Pix {
300
+ img .Pix [i ] = bgClr
301
301
}
302
302
303
303
bitmap := q .symbol .bitmap ()
@@ -308,7 +308,8 @@ func (q *QRCode) Image(size int) image.Image {
308
308
startY := y * pixelsPerModule + offset
309
309
for i := startX ; i < startX + pixelsPerModule ; i ++ {
310
310
for j := startY ; j < startY + pixelsPerModule ; j ++ {
311
- img .Set (i , j , q .ForegroundColor )
311
+ pos := img .PixOffset (i , j )
312
+ img .Pix [pos ] = fgClr
312
313
}
313
314
}
314
315
}
You can’t perform that action at this time.
0 commit comments