I tried using createBitmap but I couldn't make it work... Could anyone give me an example of how it is used?
VB Code:
Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
This has been an issue with many for a long time. I remain unclear as to why programming language authors do not provide an easy way to access image arrays. My 'opinion' is that 'they' should 'trust' users more, there-by allowing 'us' to 'have more fun'. At any rate, there is the complicated vb way of accessing Refresh buffer arrays, and there are quite a few examples on the web of how this works. Fortunately, processing in this fashion is fast, because as many know, processing an array variable takes only slightly more time than processing a regular variable.
One thing before I get started with a description of the process: bmp data recognizes blue, then green, then red, in that order.
If your image had only 1 pixel, and you define your array as byte, and your image as 32 bit,
ary(0) would be the blue byte ..
There are several methods you can use to go about defining your array.
1d vs. 2d
Type or variable
for example
Type BGRQuad
Blue as byte
Green as byte
Red as byte
Reserved as byte
end type
Dim Ary(1023,767) as BGRQuad..
Ary(40,40).Blue = 255
Ary(40,40).Green = 255
..
or you can do this
Const L = 800x600 - 1
Dim Ary(L) as byte
..
Ary(0) = 255 'Blue
Ary(1) = 0 'Green
..
It has been my experience that using a Type array is the slowest. I have a friend who mentioned that using 1d arrays are faster than using 2d, and I tried both and found that with all that I have going on in my typical 'pixel shading' renderers, they are about equal.
Understand that if you have the option of compiling for speed, that what may be slower in the vb ide may be faster in a Native code .exe.
In VB, doing things like this is slow.
Bytes(N) = Alpha
Bytes(N + 1) = Alpha
Bytes(N + 2) = Alpha
But this ends up blazingly fast in the Native code .exe
......
Take a look at the attached file. Files will unzip to 2 folders. The project in the folder " .. 2" uses a Byte array, and the regular folder uses a Type array.
Open either, and look at modFCG (drag all the way down) and you will see the array.