Puzzled in pBitmap, hBitmap and BitmapBuffer
Closed this issue · 1 comments
what I know is:
use pBitmap
: has source from rect of screent, file, clipboard and so on,
use hBitmap
: no clear source, create by CreateDIBSection
pBitmap
and hBitmap
can covert to each other.
I see BitmapBuffer
in your code, why use this?
put_window
use CreateWindowEx
instead of gui
.
too much doubt...
BTW, I write a funtion for crop
to get new postion by width, fyi ^_^
;v<0 width - abs(v)
;v<1 width * v
;v<width v
;v≥width other
forCrop(width, v, other:=0) {
if (v == 0)
return v
if (v < 0) {
v := width - abs(v)
if (v < 0)
v := other
} else if (v < 1) {
v := round(width * v)
} else if (v > width) {
v := other
}
return v
}
Hi, thanks for taking a look though the code.
The main difference is that hBitmap is used by GDI and pBitmap is used by GDI+. However, you do not have access to the pixels with both hBitmap and pBitmap. Therefore, I created BitmapBuffer to help users who want access to pixels.
Initially, I thought that just returning a buffer with the pixel data was good enough. However, I realized that people would have trouble running pixelsearch and imagesearch, so I wrote the machine code to help them.
You should only use BitmapBuffer if you need access to pixels. Otherwise it is much faster to use either hBitmap or pBitmap.