Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bgr565.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (i *BGR565) SetRGB(x, y int, c RGBColor) {

n := i.PixOffset(x, y)
pix := i.Pix[n:]
clr := (uint16(c.G)<<11) | (uint16(c.G)<<5) | uint16(c.R)
clr := (uint16(c.G) << 11) | (uint16(c.G) << 5) | uint16(c.R)

pix[0] = uint8(clr)
pix[1] = uint8(clr >> 8)
Expand Down
1 change: 1 addition & 0 deletions canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ func (c *Canvas) CurrentMode() (*DisplayMode, error) {
dm.VMode = int(v.vmode)

var pf PixelFormat
pf.Depth = uint8(v.bits_per_pixel)
pf.RedBits = uint8(v.red.length)
pf.RedShift = uint8(v.red.offset)
pf.GreenBits = uint8(v.green.length)
Expand Down
3 changes: 2 additions & 1 deletion pixelformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
// a := (pixel >> alpha_shift) & alpha_mask
//
type PixelFormat struct {
Depth uint8 // Total bit count for each pixel.
RedBits uint8 // Bit count for the red channel.
RedShift uint8 // Shift offset for the red channel.
GreenBits uint8 // Bit count for the green channel.
Expand All @@ -65,7 +66,7 @@ type PixelFormat struct {

// Stride returns the width, in bytes, for a single pixel.
func (p PixelFormat) Stride() int {
return (int(p.RedBits) + int(p.GreenBits) + int(p.BlueBits) + int(p.AlphaBits) + 7) / 8
return (p.Depth + 7) / 8
}

// Type returns an integer constant from the PF_XXX list, which
Expand Down