Can you post the parameters you use to call it, and the ToJpg() routine, so I can test it?
here you go.
VB Code:
Private Declare Function CreateStreamOnHGlobal Lib "ole32.dll" (ByRef hGlobal As Any, ByVal fDeleteOnResume As Long, ByRef ppstr As Any) As Long
Private Declare Function OleLoadPicture Lib "olepro32.dll" (ByVal lpStream As IUnknown, ByVal lSize As Long, ByVal fRunMode As Long, ByRef riid As GUID, ByRef lplpObj As Any) As Long
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpsz As Long, ByRef pclsid As GUID) As Long
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Public Function ToJpg(ByRef jpg() As Byte) As IPicture
Dim istrm As IUnknown
Dim tGuid As GUID
If Not CreateStreamOnHGlobal(jpg(LBound(jpg)), False, istrm) Then
actually here's the whole code. you can make any suggestions to make it faster, but i think what i posted is the slowest portion besides internet speed.
You need to work with Device Independent Bitmaps to make it work faster. You can use a DIB to capture the image from the picturebox and then start working with it and manipulating it as you can get the bitmap bytes to a Long array or Byte array. As you can guess, getting data from an array is way faster than calling GetPixel a few thousand times.
Unfortunatenaly I'm having a really bad day today and can't get myself focused and bright enough to show you some sample code. Though you ought to be able to find something with the search for DIB, Device Context, Bitmaps and stuff like that.
You need to work with Device Independent Bitmaps to make it work faster. You can use a DIB to capture the image from the picturebox and then start working with it and manipulating it as you can get the bitmap bytes to a Long array or Byte array. As you can guess, getting data from an array is way faster than calling GetPixel a few thousand times.
Unfortunatenaly I'm having a really bad day today and can't get myself focused and bright enough to show you some sample code. Though you ought to be able to find something with the search for DIB, Device Context, Bitmaps and stuff like that.
i found some stuff by searching google, but i was wondering if you could post some sample code if you get the time. thanks
Here is an 8-bit DIB example. It should be possible to convert that to a 32-bit DIB code: just forget about palette and set BitCount to 32. The good thing in 32-bit is that you don't have to care about the "each line much be dividable by four bytes", as 32-bit is four bytes.