Comments (15)
vcl/bitmap包里面有,另外有几个draw开头的例子,里面有相关用法。至于github……经常访问不了呗,还能怎么办,只能说习惯了这种无奈感…
from govcl.
不是说把Image以Png Decode到内存流,再从内存流Load到vcl。
vcl.IGraphic有没有类似于At、Set之类的方法读取、更改。
from govcl.
我现在需要做一个库,在Canvas上绘制图片,我已经用go Image写了一个旋转图片的代码,现在怎么在转换到vcl.IGraphic。每秒20帧,所以效率要求很高。
from govcl.
顺便问一句,作者你是怎么上Github的?我这里特别不稳定,都要被逼疯了
from govcl.
这是我封装的Bitmap,实现了go Image接口,还没写完,你看能不能用
from govcl.
package rotate
import (
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
"image"
"image/color"
"unsafe"
)
type rgba struct {
B, G, R, A uint8
}
type GoBitmap32 struct {
bmp *vcl.TBitmap
cache []uintptr
}
func (b *GoBitmap32) ColorModel() color.Model {
return color.RGBAModel
}
func (b *GoBitmap32) Bounds() image.Rectangle {
return image.Rectangle{
Min: image.Point{
X: 0,
Y: 0,
},
Max: image.Point{
X: int(b.bmp.Width()),
Y: int(b.bmp.Height()),
},
}
}
func (b *GoBitmap32) At(x, y int) color.Color {
var l uintptr
if b.cache[y] == 0 {
l = b.bmp.ScanLine(int32(y))
b.cache[y] = l
} else {
l = b.cache[y]
}
p := *(*rgba)(unsafe.Pointer(l + uintptr(x*4)))
rgbaC := color.RGBA{
R: p.R,
G: p.G,
B: p.B,
A: 255 - p.A,
}
return rgbaC
}
func (b *GoBitmap32) Set(x, y int, c color.Color) {
b.bmp.BeginUpdate(false)
defer b.bmp.EndUpdate(false)
var l uintptr
if b.cache[y] == 0 {
l = b.bmp.ScanLine(int32(y))
b.cache[y] = l
} else {
l = b.cache[y]
}
cp := (*rgba)(unsafe.Pointer(l + uintptr(x*4)))
c1 := color.RGBAModel.Convert(c).(color.RGBA)
cp.R = c1.R
cp.G = c1.G
cp.B = c1.B
cp.A = 255 - c1.A
}
func (b *GoBitmap32) Bitmap() *vcl.TBitmap {
return b.bmp
}
//Free can free the vcl.TBitmap object.
//You can also use 'bmp.Bitmap().Free()' to free the vcl.TBitmap object.
func (b *GoBitmap32) Free() {
b.bmp.Free()
}
func NewGoBitmap32(bmp *vcl.TBitmap) (goBmp32 *GoBitmap32) {
goBmp32 = new(GoBitmap32)
if bmp.PixelFormat() != types.Pf32bit {
panic("not 32 bit bitmap")
}
bmp.SetHandleType(types.BmDIB)
goBmp32.bmp = bmp
goBmp32.cache = make([]uintptr, bmp.Height())
return
}
from govcl.
问一下,Bitmap的A通道是透明度还是不透明度?为什么我一张Bitmap全部像素的A都是255?
GO好像是255为不透明,但VCL的Bitmap好像255是透明。
from govcl.
你那个写的我也不知道……只能你自己试试了。至于bmp透明必须要32位的,有一位是透明度,255就是不透明,0就是透明
from govcl.
哦,但我一张好好的位图怎么A通道全是0?导致转换出来的图片是透明的。我改成255 - A之后就好了。
from govcl.
简化代码:
l = b.ScanLine(int32(y))
p := *(*rgba)(unsafe.Pointer(l + uintptr(x*4)))
rgbaC := color.RGBA{
R: p.R,
G: p.G,
B: p.B,
A: p.A,
}
return rgbaC
这样得到的不透明部分的A是0,改成
rgbaC := color.RGBA{
R: p.R,
G: p.G,
B: p.B,
A: 255-p.A,
}
之后就好了
Set也是一样的问题
from govcl.
是我错了,不透明的确是255,但bmp.LoadFromFile("test.bmp")的结果A通道总是0,这是什么问题?
它其他通道颜色正常,只有A通道为0,这导致我认为要用255减A通道,是不是我bmp文件的问题?
from govcl.
请问怎么在画布上绘制部分透明的位图?
from govcl.
SetTransparent
SetTransparentMode
怎么使用
from govcl.
TransparentMode如果为TmAuto,就根据透明度确定是否要透明是吗?
from govcl.
你的图片是透明的绘制出来就是的,一般不需要设置什么
from govcl.
Related Issues (20)
- 运行 imageviewer demo报错 HOT 1
- TMemo & TRichEdit component can't find "SetMargin" function HOT 1
- linux 平台下,启动程序前出现莫名窗口 HOT 2
- 去掉黑框问题 HOT 4
- TPageControl has no TabVisible property available HOT 2
- 请问GoVCLDesigner😍是开源的吗? HOT 2
- initFile 中readDate、readTime、readDateTime三个返回的是0,导致解析成1970-01-01.... HOT 2
- res2go doesn't work. HOT 8
- 这几个组件是不支持吗? HOT 2
- res2go插件包名无法删除 HOT 1
- 生成名称属性已更改的控件时出错 HOT 2
- 怎么让一个画布重绘? HOT 2
- example中有很多gfm文件,用lazarus也打不开啊。要怎么转换格式才能打开呢 HOT 2
- 报错 HOT 3
- Button的Caption值能否支持换行,或使用其他控件 HOT 1
- TreeView再SetData后,用Data函数得到的指针总是错的。TreeNode的地址总是在改变,尽管里面的Instance指针是不变的 HOT 1
- 能否支持Virtual TreeView呢? HOT 1
- windows系统下,管理员检测不对 HOT 2
- MacOS 下面XButton的Caption字体模糊 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from govcl.