A: bitmap-bit-buffer proc

This commit is contained in:
杨红岩 2023-06-21 12:08:17 +08:00
parent b869ad5ec4
commit c17383132c
4 changed files with 90 additions and 2 deletions

View File

@ -4,13 +4,16 @@
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
// https//www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package cef
import (
"github.com/energye/energy/v2/cef/internal/def"
"github.com/energye/energy/v2/common/imports"
"github.com/energye/golcl/lcl/api"
"unsafe"
)
@ -18,9 +21,18 @@ type TCEFBitmapBitBuffer struct {
instance unsafe.Pointer
}
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
}
func (m *TCEFBitmapBitBuffer) Free() {
if m.instance != nil {
//imports.SysCallN(def.BufferPanel_Free, m.Instance())
imports.SysCallN(def.BitmapBitBuffer_Free, m.Instance())
m.instance = nil
}
}
@ -32,3 +44,43 @@ func (m *TCEFBitmapBitBuffer) Instance() uintptr {
func (m *TCEFBitmapBitBuffer) IsValid() bool {
return m.instance != nil
}
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())
}

View File

@ -1,3 +1,15 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
// gtk3 Manually calling initialization
package gtk
import (

View File

@ -1959,6 +1959,18 @@ const (
CefDomNode_SetElementAttribute
CefDomNode_GetElementInnerText
CefDomNode_GetElementBounds
// TCEFBitmapBitBuffer
BitmapBitBuffer_Create
BitmapBitBuffer_Free
BitmapBitBuffer_UpdateSize
BitmapBitBuffer_Width
BitmapBitBuffer_Height
BitmapBitBuffer_BufferLength
BitmapBitBuffer_Empty
BitmapBitBuffer_Scanline
BitmapBitBuffer_ScanlineSize
BitmapBitBuffer_BufferScanlineSize
BitmapBitBuffer_BufferBits
// TBufferPanel
BufferPanel_Create
BufferPanel_Free

View File

@ -1959,6 +1959,18 @@ func init() {
dllimports.NewEnergyImport("CefDomNode_SetElementAttribute", 0),
dllimports.NewEnergyImport("CefDomNode_GetElementInnerText", 0),
dllimports.NewEnergyImport("CefDomNode_GetElementBounds", 0),
// TCEFBitmapBitBuffer
dllimports.NewEnergyImport("BitmapBitBuffer_Create", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_Free", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_UpdateSize", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_Width", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_Height", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_BufferLength", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_Empty", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_Scanline", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_ScanlineSize", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_BufferScanlineSize", 0),
dllimports.NewEnergyImport("BitmapBitBuffer_BufferBits", 0),
// TBufferPanel
dllimports.NewEnergyImport("BufferPanel_Create", 0),
dllimports.NewEnergyImport("BufferPanel_Free", 0),