C++ DIB's

S

Sueffel

I'm sure this has been asked, but I cannot fid it. I have a DLL (Not mine,
3rd party) and the documentation simply says "Return DIB". Well, since this
sucker was made with C++, I'm at a complete loss. Basically, this sucker
returns the pointer to the DIB as an Object, which is odd on me. So, I need
to load this thing into a picturebox and display it, then maybe save it
later. I also may need to load picture from file and throw it as a DIB
back into this DLL. If someone wants to walk me through it, I could even
post whatever structure this thing is returning. There's alot of unknowns,
and graphics is my least favorite subject (reqiures too much thought).

Thanks in advance,
Sueffel
 
S

Sueffel

This will not help. I have a function, the prototype is "GetDIB(ByRef
DIBObj as Integer)"
That, and all the marshelling, VB.NET can't do.

Thanks,
Sueffel
 
S

Scott

From your earlier post you said that the DIB was returned as an object. The
thread I referenced is C# code that shows how to retrieve a DIB from a
drag/drop event (as an object) and convert it to an image. This code could
easily be rewritten in VB (with all of the marshalling) as shown below.

Imports System.Runtime.InteropServices

Dim obj As Object = e.Data.GetData(DataFormats.Dib)
Dim stream As System.IO.MemoryStream = CType(obj,
System.IO.MemoryStream)
If (Not stream Is Nothing) Then
Dim img As Byte() = stream.ToArray()
Dim p As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(img(0))
* img.Length)
Marshal.Copy(img, 0, p, img.Length)
Try
PictureBox1.Image = TwainGui.DibToImage.WithStream(p)
Finally
Marshal.FreeCoTaskMem(p)
End Try
End If

Your's would simply begin with

Dim obj as Object = GetDIB(ByRef DIBObj as Integer)

The only thing left to do is convert the "TwainGui.DibToImage.WithStream"
function from C# to VB.NET. This can be downloaded in a ZIP file referenced
in the thread. If you have trouble converting it then post your problems
here. If I've misunderstood the problem, feel free to correct me or provide
more information.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top