energy/cef/bitmap-bit-buffer.go

87 lines
2.3 KiB
Go
Raw Normal View History

2023-06-17 18:20:42 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
2023-06-21 12:08:17 +08:00
// https//www.apache.org/licenses/LICENSE-2.0
2023-06-17 18:20:42 +08:00
//
//----------------------------------------
package cef
import (
2023-06-21 12:08:17 +08:00
"github.com/energye/energy/v2/cef/internal/def"
"github.com/energye/energy/v2/common/imports"
"github.com/energye/golcl/lcl/api"
2023-06-17 18:20:42 +08:00
"unsafe"
)
type TCEFBitmapBitBuffer struct {
instance unsafe.Pointer
}
2023-06-21 12:08:17 +08:00
func NewBitmapBitBuffer(width, height int32) *TCEFBitmapBitBuffer {
var result uintptr
imports.SysCallN(def.BitmapBitBuffer_Free, uintptr(unsafe.Pointer(&result)))
if result > 0 {
return &TCEFBitmapBitBuffer{instance: getInstance(result)}
}
return nil
}
2023-06-17 18:20:42 +08:00
func (m *TCEFBitmapBitBuffer) Free() {
if m.instance != nil {
2023-06-21 12:08:17 +08:00
imports.SysCallN(def.BitmapBitBuffer_Free, m.Instance())
2023-06-17 18:20:42 +08:00
m.instance = nil
}
}
func (m *TCEFBitmapBitBuffer) Instance() uintptr {
return uintptr(m.instance)
}
func (m *TCEFBitmapBitBuffer) IsValid() bool {
return m.instance != nil
}
2023-06-21 12:08:17 +08:00
func (m *TCEFBitmapBitBuffer) UpdateSize(width, height int32) {
imports.SysCallN(def.BitmapBitBuffer_UpdateSize, m.Instance(), uintptr(width), uintptr(height))
}
func (m *TCEFBitmapBitBuffer) Width() int32 {
return int32(imports.SysCallN(def.BitmapBitBuffer_Width, m.Instance()))
}
func (m *TCEFBitmapBitBuffer) Height() int32 {
return int32(imports.SysCallN(def.BitmapBitBuffer_Height, m.Instance()))
}
func (m *TCEFBitmapBitBuffer) BufferLength() int32 {
return int32(imports.SysCallN(def.BitmapBitBuffer_BufferLength, m.Instance()))
}
func (m *TCEFBitmapBitBuffer) Empty() bool {
return api.GoBool(imports.SysCallN(def.BitmapBitBuffer_Empty, m.Instance()))
}
// Scanline
// return PByte = byte pointer
func (m *TCEFBitmapBitBuffer) Scanline(i int32) uintptr {
return imports.SysCallN(def.BitmapBitBuffer_Scanline, m.Instance(), uintptr(i))
}
func (m *TCEFBitmapBitBuffer) ScanlineSize() int32 {
return int32(imports.SysCallN(def.BitmapBitBuffer_ScanlineSize, m.Instance()))
}
func (m *TCEFBitmapBitBuffer) BufferScanlineSize() int32 {
return int32(imports.SysCallN(def.BitmapBitBuffer_BufferScanlineSize, m.Instance()))
}
// BufferBits
// Bits Pointer
func (m *TCEFBitmapBitBuffer) BufferBits() uintptr {
return imports.SysCallN(def.BitmapBitBuffer_BufferScanlineSize, m.Instance())
}