Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/exp/shiny/driver/windriver: Consider using BV4*Mask instead of swizzle.BGRA(b.buf) #16972

Closed
vasiliicuhar opened this issue Sep 2, 2016 · 3 comments

Comments

@vasiliicuhar
Copy link

Hi, everyone.
Why not use BITMAPV4HEADER fields BV4{Red, Green, Blue }Mask instead of moving bytes around?
https://github.com/golang/exp/blob/master/shiny/driver/windriver/windraw.go#L19

bi := internal.BITMAPV5HEADER{}
bi.Size = uint32(unsafe.Sizeof(bi))
bi.Width = int32(size.X)
bi.Height = -int32(size.Y)
bi.Planes = 1
bi.BitCount = 32
bi.Compression = internal.BI_BITFIELDS
bi.SizeImage = uint32(size.X * size.Y * 4)


// no bytes shuffling
bi.BV4RedMask = 0x000000FF
bi.BV4GreenMask = 0x0000FF00
bi.BV4BlueMask = 0x00FF0000
bi.BV4AlphaMask = 0xFF000000

var ppvBits *byte
hbitmap, err := internal.CreateDIBSection(0, &bi, internal.DIB_RGB_COLORS, &ppvBits, 0, 0)

I`ve tried it on my Windows 10 machine, and it works quite well.
Should be supported from Windows 2000.

@alexbrainman
Copy link
Member

@ngreduce that sounds like good suggestion to me. Would you like to send a change to implement this? See https://golang.org/doc/contribute.html for how to contribute.

Thank you very much.

Alex

@vasiliicuhar
Copy link
Author

Yes, I can send a patch to Gerrit next week.
Issue was opened in case there is a known drawback with this change.

@quentinmit quentinmit modified the milestone: Unreleased Sep 6, 2016
@vasiliicuhar
Copy link
Author

Having subtle bugs with red and blue channels jumping around.
Current shiny implementation seems more reliable. I will reopen issue later, if will have any ideas why that happens.

@golang golang locked and limited conversation to collaborators Sep 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants