Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Create STRING Buffer Of A GetDIBits And SetDIBits


If someone wanted to stream a image in a picture box to another picture box on a different computer on a local network and WITHOUT saving to the hard drive on either machine, how might I go by doing this?

I need the actual code for it, since I have no clue of how GetDIBits/SetDIBits can buffer into an actual "String" data format and not into a DC.

Does anyone have a code to do this?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Reading Image Files Into A String Buffer(since API Function Supports Only String Buf)
Hai all,

im back with another problem!

I am using a API function which accepts data only into a string buffer. (InternetReadFile function in WinINet API).

I tried reading a JPG file from the cache and then writing it out again to disk. I didnt get back a JPG image.

So how do we work around the fact that InternetReadFile reads into a string buffer, but I need the data in a Byte() array, so that I can write back the JPG file properly to disk??

converting each character in the string to Bytes returned an error..


Code:


'Buffer is the string and data is the Byte()
For i = 1 To Len(Buffer)
data(i)= CByte(Mid(Buffer, i, 1))
Next



sorry if im missing something!

thanks for ur time..

Pradeep V

Reading Image Files Into A String Buffer(since API Function Supports Only String Buf)
Hai all,

I am using a API function which accepts data only into a string buffer. (InternetReadFile function in WinINet API).

I tried reading a JPG file from the cache and then writing it out again to disk. I didnt get back a JPG image.

So how do we work around the fact that InternetReadFile reads into a string buffer, but I need the data in a Byte() array, so that I can write back the JPG file properly to disk??

converting each character in the string to Bytes returned an error..


Code:

'Buffer is the string and data is the Byte()
For i = 1 To Len(Buffer)
data(i)= CByte(Mid(Buffer, i, 1))
Next


sorry if im missing something!

thanks for ur time..

Pradeep V

How To Create A FIFO Buffer In VB ?
Good Morning All,

I am sitting here staring at the screen, with a "VBNull$" look on my face, trying to figure this out. My brain cells are overlaoded with caffeine. I swear, the refresh rate on my screen has now dropped down to about 2 in the last hour. Totally Groovy Man!

Anyway, here's what I am trying to figure out...

I need a 3 line buffer to hold about 5 data elements (variants).

Ex:

Buffer line 1: A,B,C,D,E
Buffer line 2: X,1,3,e,E
Buffer line 3: 2,2,2,2,2

Values (Current or whatever is added) in to the BUFFER need to be there as long as the program is running, and I need to be able to add new data at LINE1 and read data at line 3. When new data is added, current data needs to be shifted down and contents of line 3 flushed out. In other words, when new data comes in;

Line 3 flushes out and gets data from line 2. Line2 will now get it's data from line 1 & line 1 will have the new data.

I am still a little confused about array's and how to load data to a certain location.

How do I go about dimensioning an array that "ONLY" have 3 line and 5 elements (columns)?

Can anyone help guide me in the right direction as to how to go about doing this?

Thanks.

Support For 16-bit And SetDIBits
I'm expanding on a program that reads multiple DIB data from a file and displays it in pictureboxs. The datafile format have been changed by the author to support 16-bit bitmaps. My program currently support 8-bit and 24-bit bitmaps, but not 16-bit graphics.

There is not much information on "high color" modes to be found.

After a little research, I've concluded the new format includes...

DIBs in the 5:6:5 format
.biBitCount = 16
.biCompression = 3

Following the BITMAPINFOHEADER, the bit masks are stored in order Red-00 F8 00 00, Green-E0 07 00 00, Blue-1F 00 00 00, followed by the pixel data.

Questions...

1. I think it is possible to just read the DIB data and then display it using SetDIBits like I'm doing with the 8-bit and 24-bit pixel data. I am I off base on this one? (Haven't made it work yet, could easily be my stupidity)

2. Or do I need to convert the 16-bit data to 24-bit and rewrite the BITMAPINFOHEADER information to reflect the 24-bit conversion? (I could use some tutoring on "slicing" the red, green, and blue bitfields from the pixel data.)

I've found some code to convert to RBG data but I believe the bit masks are suppose to be involve in the process.

Blue = (pixel& And &HFF&)
Green = (pixel& And &HFF00&) &H100&
Red = (pixel& And &HFF0000) &H10000

vs.

Blue = pixel& & maskBlue
Green = pixel& & maskGreen
Red = pixel& & maskRed

Any help would be appreciated.

Here is a snip on the code that SetDIBits the 8 and 24 bit pixel data.

With OpenBitMapInfo.bmiHeader
If .biBitCount = 8 Then
ReDim ColorTable(2 ^ .biBitCount)
For i = 0 To (2 ^ .biBitCount) - 1
Get #1, , ColorTable(i)
Next i
ReDim SaveBitsLong(.biHeight * .biWidth) as Long
ReDim chColor(.biHeight * .biWidth) as Long
k = 0
For i = 1 To .biHeight
For j = 1 To .biWidth
Get #1, , chColor(k)
k = k + 1
Next j
If .biWidth Mod 4 = 1 Then
Get #1, , chTrash
Get #1, , chTrash
Get #1, , chTrash
ElseIf .biWidth Mod 4 = 2 Then
Get #1, , chTrash
Get #1, , chTrash
ElseIf .biWidth Mod 4 = 3 Then
Get #1, , chTrash
End If
Next i
For i = 0 To (.biWidth * .biHeight) - 1
SaveBitsLong(i) = ColorTable(chColor(i))
Next i
retVal = SetDIBits(PictureBox.hDC, _
PictureBox.Image.Handle, _
0, _
OpenBitMapInfo.bmiHeader.biHeight, _
SaveBitsLong(0), _
OpenBitMapInfo, _
DIB_RGB_COLORS)

ElseIf .biBitCount = 16 Then

????????????????????????????????????????????????????

Elseif .biBitCount = 24 then
bytesperline = ((.biWidth * 3 + 3) And &HFFFC)
buffersize = bytesperline * .biHeight
ReDim SaveBitsByte(0 To buffersize - 1) As Byte
For i = 0 To buffersize - 1
Get #1, , SaveBitsByte(i)
Next i
retVal = SetDIBits(PictureBox.hDC, _
PictureBox.Image.Handle, _
0, _
OpenBitMapInfo.bmiHeader.biHeight, _
SaveBitsByte(0), _
OpenBitMapInfo, _
DIB_RGB_COLORS)
End If
End With

Here's the complete program...

http://home.nc.rr.com/afishe/GTLTextEditor/

String Buffer?
Hi everyone,


I was wondering, does VB have a string buffer that can hold any amount of data besides just declaring a string or a variant?

If so, can someone tell me what it is please.


Thanks,

[NOT RESOLVED YET] Can Anyone Please Explain SetDIBits/SetDIBitsToDevice?
I've searched the whole internet and all i find is advanced functions which i can't break down to understand.

May i please ask anyone to give a brief explanation, and a most BASIC use.
(the 'target use' i am trying to achieve is to use it like SetPixel, 'OR' to change an image rgb)
I hear these API calls are much much faster.

Cheers ~

Writing To A String Buffer...
Hello all, I have a question that maybe somebody could help me with...

I'm creating a string buffer, that input from a file is stored into; however, as the string buffer becomes larger the application slows WAY down. How would I make this faster!? I recall a method once (perhaps I was just dreamin') where a person filled the string with spaces (the length of the file)... which reserved it's place in the system memory... then wrote to the string buffer (which made it faster).

How would I go about doing this?

Respectfully,

Eric D. Brown

Splicing A String Buffer
When reading in a text file into a buffer as a string. To break the strings up into string what is the best way to do this?

What Is A String-buffer? I'm Confused...
I got this from http://www.allapi.net/ and I'm confused as to why it's necessary to set sText = 255 spaces in order for this to work.
If I just leave it blank, the function doesn't put anything in it.
This is a new concept for me.
Can someone explain this to me please?
Seems weird....

Public Function EnumThreadWndProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
Dim Ret As Long, sText As String
'create a string-buffer
sText = Space(255)
'get the classname of the window handle
Ret = GetClassName(hWnd, sText, 255)
'cut off the unnecessary part of Chr$(0)'s
sText = Left$(sText, Ret)
'add this classname to the list of classnames
sClasses = sClasses + sText + vbCrLf
'continue the enumeration
EnumThreadWndProc = 1
End Function

Stuff Like Buffer$ = String$(250,0)
Okay, I have not been doing any VB programming for about 2 years, and now I need to remember a few things.

1st) I am having trouble remembering what exactly does this statement do:

buffer$ = string$(250,0)

2) how would i convert this statement to vb.net

3) How do i do dimblah as string*250 in vb.net

String Buffer Question
This is the code I have trouble with.
Code:

Dim cwp As CWPSTRUCT
Dim buffer As String

buffer = Space(32)
GetWindowText cwp.hwnd, buffer, 32
buffer = Trim(buffer)
MsgBox buffer
If buffer = "Open" Then

End If



Message box show text "Open". But the if-statement is not true. Any idéas what can be wrong?

Best regards

String Data From Buffer To Array
I am trying to recieve a long string of data through comm port (eg. 123456789abcdefgh) and then scan it into array (eg. array(1) = 1, array(10) = a ) But the buffer seem to be restricted to 8 Chars so the array always is 1 to 8 then repeat again.(eg. array(1)...array(8)= 1.....8 & NEXT array(1).......array(8) = 9abcdefg)

This is the code which produce the repeated array but with the correct data.

Dim rBuffer, HexNumber, HexLen, LastNum, HexLenTotal As String
Dim Counter As Integer

HexNumber = 0
HexLen = 0
Counter = 0
HexLenTotal = 0

rBuffer = MSComm1.Input
'Call HandleInput(rBuffer)

HexNumber = rBuffer
HexNumber = UCase(HexNumber)
HexLen = Len(HexNumber)

Do
LastNum = Mid(HexNumber, HexLen, 1)
Print "Array(" + Str(HexLen) + ") =" + _
LastNum

HexLen = HexLen - 1

Loop Until HexLen = 0

How can i make the rbuffer recieving the string data to collect all chars at one go instead of 8 chars at a time?
Thanks.

XML Node Text And UDT Buffer String...!!!
OK I have:

VB Code:
Public Type gtypStructureProps    IsNew           As Boolean    IsDirty         As Boolean    IsDeleted       As Boolean    Key             As String * 36    ID              As Long    Description     As String * 30End Type Public Type gtypStructureData    Data            As String * 72End Type

Which are the UDTs for my table tblStructures...
Now, in the load event I have:

VB Code:
Set adoRec = New Recordset    With adoRec        .Open strSQL, DB_CONN, adOpenForwardOnly, adLockReadOnly        Do While Not .EOF                    Set objRoot = objDOM.createElement("Structure")                        udtProps.ID = .Fields("ID").Value            udtProps.Description = .Fields("Description").Value            udtProps.Key = vbNullString            udtProps.IsNew = False            udtProps.IsDirty = False            udtProps.IsDeleted = False            LSet udtData = udtProps                                Set objProp = objDOM.createElement("UDT")            objProp.Text = "Q" & udtData.Data & "P"            Debug.Print objProp.Text            Debug.Print udtData.Data            objRoot.appendChild objProp            Set objProp = Nothing

My udtData.Data is a string and contains the data from the props UDT, and the debug.print statement proves that it contains the correct data...HOWEVER! When I assign this string to the text property of an XML node all the data vanishes!!!
The debug.Print objProp.Text just prints "Q" to the immediate window...the trailing "P" AND all the data vanishes!!!
Is there something up with XML that stops me doing this???

Woka

Invalid String Or Buffer Length
I'm facing this error : "Invalid string or buffer length" while trying to generate a data report. How to debug it?

String For Binary Access Or Into Array--buffer
i copy data from buffer into a string to save to a file

I need to display the values while inputs enter the buffer... how can i display the values as they enter the buffer?

Since i store the data from buffer to a string , i think i can convert the string into a array of bytes or integers in order to display the value, how can i do it? by using split function? array = split (string, "???") if i were to store into arrays of bytes or integers what shd i put in "???" ?

Anyone got suggestions of directing inputs from buffer for display and save to a file?

thank you

A Function To Send A String Or Buffer Of Text And Return In HTML?
Is there such a function in VB or Windows API to to send a string or buffer of text and return in HTML?

Accessing Or Managing A Harware Buffer Like CD Writer Buffer
Respected Members,
I like to know about, how can we access or manage a hardware buffer area using vb 6.0. Actually I mean A cd writer buffer. Is it is possible to read data from H/w buffers.
Faithfully
Sandeep Thomas

About GetDIBits
I was wondering how I would use GetDIBits to store arrays of pixels from clipboard after doing print screen. From these arrays of pixels than I will start searching for the pixels I want.

I searched online for tutorials and even read up on GetDIBits. But to dismay I failed to understand how to use it efficiently to make it work at all. I was hoping someone could provide me sample code.

GetDIBits
Hi I found an attachment from this site on using GetDIBits to rotate image.....

I want to use the function to convert the image into grayscale.....

But I having trouble accessing the color components.....

the GetDIBits reads the image pixels into bits(x,y) array...

bits array is declared as dim bits() as rgbQUAD

Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
end type

I have tried this
bits(x,y).rgbRed 'Red comp
bits(x,y).rgbGreen 'Green comp
bits(x,y).rgbBlue 'Blue comp

but when I compared the pixels color values with other program like PhotoShop program, it does look anything similar.....

Now when we call the GetDIBits(,,,,,,bits(0,0),,,,,,)
it this function scane the image pixels from top left downward.....????

Thanks....

GetDIBits
When getting the bits from a bitmap, they seem to be placed in a 3 dimensional byte array

Is there a good way to fit this in a single dimension byte array, so that when it is sent over a socket, its in the correct order as if it was written binary to file.

I am having trouble sending a 3 dimensional array from getdibits onto the network.

GetDIBits
Hi there,
I've a DIB Section in which there's a graphic.Now I want to get its bits using GetDIBits in vb.Can anybody help me in this..?

Regards,
Asim Siddiqui.

GetDIBits
I just want to print lines and polygon which are in a PictureBox control.

The GetDiBits function always (and i mean ALWAYS) return 0 wich mean that something went wrong. Even by pasting the MicroSoft code it return 0

Is this function still Working


SOS

How To Use GetDIBits And StretchDIBits?
Could you somebody tell me how to use API code?

Using The GetDIBits API Call
I am trying to load bitmap data from a form into a bitmap structure so that i can write it to disk. I have successfully used the BitBlt call to copy the bitmap from the form to a Memory DC (using a compatible bitmap) and I have then ensured that the bitmap isn't currently selected into the memory DC (since i read that GetDIBits doesn't work if the bitmap is currently selected into any DC's).

I have setup the BitmapInfoHeader and BitmapInfo structures using an array of 256 RGBQUAD structures. And I have specified the biBitCount value in the bitmapinfoheader structure to be 8 (256 colours).

I have used GlobalAlloc and GlobalLock calls to successfully allocate memory for the bitmap bits. To calculate the amount of memory to allocate for the bitmap i have simply multiplied the imageheight by the imagewidth by the number of bits per pixel (and multiplied this by 8 to get the number of byted reqd.) ...Is this correct?

Sofar so good....now when i call the GetDIBits function it is failing. As far as i can tell I am doing everything correctly. I am running VB6 Professional, on Win98.

Any Ideas Appreciated...

regards,
Michael Yates
michael@diginetix.com.au

Using The GetDIBits API Call
I am trying to load bitmap data from a form into a bitmap structure so that i can write it to disk. I have successfully used the BitBlt call to copy the bitmap from the form to a Memory DC (using a compatible bitmap) and I have then ensured that the bitmap isn't currently selected into the memory DC (since i read that GetDIBits doesn't work if the bitmap is currently selected into any DC's).

I have setup the BitmapInfoHeader and BitmapInfo structures using an array of 256 RGBQUAD structures. And I have specified the biBitCount value in the bitmapinfoheader structure to be 8 (256 colours).

I have used GlobalAlloc and GlobalLock calls to successfully allocate memory for the bitmap bits. To calculate the amount of memory to allocate for the bitmap i have simply multiplied the imageheight by the imagewidth by the number of bits per pixel (and multiplied this by 8 to get the number of byted reqd.) ...Is this correct?

Sofar so good....now when i call the GetDIBits function it is failing. As far as i can tell I am doing everything correctly. I am running VB6 Professional, on Win98.

Any Ideas Appreciated...

regards,
Michael Yates
michael@diginetix.com.au

How To Use The GetDIBits() Function ?
How to I use the GetDIBits() function to get every 64 bits of pixel on an image?
Although a pixel has 24 bits(RGB), but I need to get 64 bits which might be 2 pixels or 3 pixels at any one time.

Please help.

Dev.

Buffer Or Not 2 Buffer? PLEASE READ, EVEN IF YOU DON'T KNOW BUFFERS.
Some books I have been reading, which date back to 98, say that when passing data from the business teir to the UI you shud use a buffer, and then it goes into loads of programming techneques to deal with buffers. Is there any need?
I know if the LAN is slow then a buffer may be a good idea, but with todays computers, servers and LAN connections, is there any need to use buffers?

Manipulating Bitmaps With GetDIBits
Hey,

I found alot of sourcecodes about this but every time i try to add it to my form something goes wrong.

i think its because i didnt understand completly how to use this API

i know u need the bitmap info and the scales of the pictures
(which btw , i didnt understand the diffrence between Width and ScaleWidth)

i also found out that if the scale is not pixels getdibits returens 0

can anyone show me the simplest source WITH EXPLANSIONS on how to use this API and SetDIBits

i just want to load a picture to Array and than to change the colors and write it again - i heard dibs are very fast


if someone can give me a BAS with made functions like

loadbitmaptoarray pic,bits()


its not as good as understanding it , but its something


10x

Damned GetDIBits ! Damn It !
THIS **** CODE IS FREAKING ME OUT !

Public Declare Sub GetDIBits Lib "gdi32" _
(ByVal hdc As Long, _
ByVal hbmp As Long, _
ByVal uStartScan As Long, _
ByVal cScanLines As Long, _
ByVal lpvBits As Long, _
ByVal lpdi As Long, _
ByVal uUsage As Long)

Public Const DIB_RGB_COLORS = 1

Private Sub Form_Load()
ProgramDC = MonitorScreen.hdc
ScreenDC = GetWindowDC(0)
ImageDC = ImgField.hdc
End Sub

Call GetDIBits(ScreenDC, ScreenDC, 0, 0, pic(), DIB_RGB_COLORS)

THE ****ING VB SAID Argument not optional (Error 449)

**** IT

Bitmap Pixel Aceess With GetDiBits
Hi

Im doing a face detection project in which I capture a frame (face and background) from a video camera and save it as a bitmap picture. I then need to search the entire picture for non-skin colors and replace it with white, thus leaving just the face.

I need help on how to search for a specific pixel color in a bitmap and replace the pixel color with another colour. I wanna also save the new bitmap with the new pixel color. How do I manipulate each pixel and once its maniplulated how do I save it as a bitmap again to view.

I saved the original image as a device independent bitmap and I want to know how to access the pixels using GetDIbits.

This is my code so far

capGrabFrameNoStop(hwnd1);//grabs a frame from the video stream and fills the frame buffer
capFileSaveDIB(hwnd1,"orig.bmp");//saves the captured frame

Combining String Data To Create A New String Name
Okay I'm new here and have a question on how I'd go about combining data from strings to a new string name... for example:

I have a string already defined :
Code:
Branch1 = Birmingham

I have multiple Branches so the variables are followed by numbers.

I then have a FOR loop where I want to combine the number of times the FOR looped has looped with the data from the "Branch1" string.


Code:
Subjectn = "Branch" & counter


"counter" is the number of times the FOR loop has looped.

I know this isn't right. But essentially above I want Subjectn to equal the data of string "Branch1".

Thanks.

GetDIBits, BitBlt? Finding An Image On The Screen.
Hi,
I'm trying to search the screen for a set bmp, basically I want to scan the screen until it finds a certain image, then return the coordinates of the image. I'm just not sure what the most appropriate or effective way of doing this is.

For instance, I have a picture of a Directory Icon. I want to be able to scan the screen, say on the desktop and it return the location of where it found the image.

Any theories or examples etc are much appreciated.

Cheers

Get Color Pixels From Desktop Into Array... GetDIBits
i want a way to get the pixels from the desktop into an array without the WICKED slow getpixel... so after TONS of research ive found you can do it with GetDIBits (atleast i believe so... im still trying to grasp the concept)

so ive used a few different references and msdn and my code looks like this so far

Code:
Private Sub Command2_Click()
Dim hDCSrc As Long, hDCDest As Long, hDCBmp As Long, lHandle As Long, lHandle1 As Long, lResult As Long, lBMap As Long, bInfo As BITMAPINFO, lDIB As Long
Dim CQ() As RGBQUAD
lHandle = GetDesktopWindow
If lHandle Then
    hDCSrc = GetWindowDC(lHandle)
    If hDCSrc Then
        hDCDest = CreateCompatibleDC(hDCSrc)
        If hDCDest Then
        DoEvents
            lBMap = CreateCompatibleBitmap(hDCDest, Screen.Width, Screen.Height)
            If lBMap Then
                lHandle1 = SelectObject(hDCDest, lBMap)
                If lHandle1 Then
                    BitBlt hDCDest, 0, 0, Screen.Width, Screen.Height, hDCSrc, 0, 0, vbSrcCopy
                    With bInfo.bmiHeader
                        .biSize = Len(bInfo.bmiHeader)
                        .biWidth = Screen.Width ' Width in pixels.
                        .biHeight = Screen.Height ' Height in pixels.
                        .biPlanes = 1 ' 1 color plane.
                        .biBitCount = 32 ' 24 bits per pixel.
                        .biCompression = BI_RGB ' No compression.
                        .biSizeImage = 0 ' Unneeded with no compression.
                        .biXPelsPerMeter = 0 ' Unneeded.
                        .biYPelsPerMeter = 0 ' Unneeded.
                        .biClrUsed = 0
                        .biClrImportant = 0
                    End With
                    hDCBmp = GetWindowDC(lHandle)
                    hDCBmp = CreateCompatibleDC(hDCBmp)
                    If hDCBmp Then
                        ReDim CQ(1 To Screen.Width / 15, 1 To Screen.Height / 15)
                        lResult = GetDIBits(hDCDest, lBMap, 0, Screen.Height / 15, CQ(1, 1), bInfo, DIB_RGB_COLORS)
                        MsgBox lResult
                    End If
                End If
            End If
        End If
    End If
End If
End Sub


with everything declared ... everything returns right except the lResult from GetDIBits ... anyone familiar with this and know how to help?

[Solved] - GetDIBits - Picturebox Pixel Retrieval
Hi VBcitizens,

I discovered a strange occurrence within an old project of mine and I can't get my head around why this is happening.

I'm using GetDIBits to retrieve the pixel data from a picturebox.
This has always worked fine untill I had a 499w 300h image in the picturebox.

Whenever I call GetDIBits then it raises an "memory could not be written" error. (or sometimes closes without any report)

I don't understand why a 500/300 image works and a 499/300 image doesn't when calling GetDIBits.

Anyone knowns what could be the cause of this?

part of source:
Code:
Option Explicit

Private Type RGBTRIPLE
   rgbBlue As Byte
   rgbGreen As Byte
   rgbRed As Byte
End Type

Private Type BITMAP
    bmType As Long
    bmWidth As Long
    bmHeight As Long
    bmWidthBytes As Long
    bmPlanes As Integer
    bmBitsPixel As Integer
    bmBits As Long
End Type
 
Private Type BITMAPINFOHEADER
    bmSize As Long
    bmWidth As Long
    bmHeight As Long
    bmPlanes As Integer
    bmBitCount As Integer
    bmCompression As Long
    bmSizeImage As Long
    bmXPelsPerMeter As Long
    bmYPelsPerMeter As Long
    bmClrUsed As Long
    bmClrImportant As Long
End Type
 
Private Type BITMAPINFO
    bmHeader As BITMAPINFOHEADER
    bmColors(0 To 255) As RGBTRIPLE
End Type

Private Const DIB_RGB_COLORS = 0

Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, _
                                                                   ByVal nCount As Long, _
                                                                   ByRef lpObject As Any) _
                                                                   As Long

Private Declare Function GetDIBits Lib "gdi32" (ByVal hDC As Long, _
                                                ByVal hBitmap As Long, _
                                                ByVal nStartScan As Long, _
                                                ByVal nNumScans As Long, _
                                                lpBits As Any, _
                                                lpBI As BITMAPINFO, _
                                                ByVal wUsage As Long) _
                                                As Long

Private Type tIMG_DATA
    bm As BITMAP
    px() As Byte
End Type

Private Sub Form_Load()

    Me.ScaleMode = vbPixels
    Picture1.ScaleMode = vbPixels
    Picture1.AutoRedraw = True
    Picture1.AutoSize = True
    Picture1.Picture = LoadPicture(App.Path & "eetle.bmp")
    
End Sub

Private Sub Command1_Click()

    Dim myIMG As tIMG_DATA
    Get_ImageData Picture1, myIMG
    
End Sub

Private Sub Get_ImageData(PBox As PictureBox, thisIMG As tIMG_DATA)

    GetObject PBox.Image, Len(thisIMG.bm), thisIMG.bm
    
    Dim bmi As BITMAPINFO
    bmi.bmHeader.bmSize = 40
    bmi.bmHeader.bmPlanes = 1
    bmi.bmHeader.bmBitCount = 24
    bmi.bmHeader.bmCompression = 0
    bmi.bmHeader.bmWidth = thisIMG.bm.bmWidth
    bmi.bmHeader.bmHeight = thisIMG.bm.bmHeight
    
    ReDim thisIMG.px(0 To 2, 0 To thisIMG.bm.bmWidth - 1, 0 To thisIMG.bm.bmHeight - 1)
    
  ' error occurrence
    GetDIBits PBox.hDC, PBox.Image, 0, thisIMG.bm.bmHeight, thisIMG.px(0, 0, 0), bmi, DIB_RGB_COLORS
    
  ' no error occurrence when substracting 1 from the nNumScans,
  ' but then the pixel array is missing an edge...
  ' GetDIBits PBox.hDC, PBox.Image, 0, thisIMG.bm.bmHeight - 1, thisIMG.px(0, 0, 0), bmi, DIB_RGB_COLORS
    
End Sub


=============================================
aka Red2048.

Edited by - T48 - [RedPlanet] on 5/21/2007 5:36:32 PM

Converting Picture To Binaire Info To Send Through Winsocket With GetDIBits
GetDIBits ?? i read it everywhere use this to get a picturebox's info and send it over the winsock. i dont really know how to use this and how to reconvert it? i cant find any examples or something on it , basicly what i am trying to do is grab the user's desktop to a picture box of 320x200 and send it to a client wich will be able to see a small window of what the person is doing how to send it? any examples?

Create Sql String Using Vb
Hello,
I have a cvs file that I pulled into an access and now I want to pull the
data and put it in a sql string like 23,33,41,45, pulling the numbers for
the table in access or the xls file it don't matter. I just need to create a
string out of the data to feed to sql.
Numbers are too much to type in by hand. Thanks
Template_id
600988
600991
600993
600995
601000
601005
601006
601041
601044
601045
601070
601088
601092
601097
601101
601102
601147
601149
601161
601162
601169
601171
601185
601186
601187
601188
601189
601193
601202
601205
601217
601222
601257
601267
601268
601269
601270
601271
601272
601273
601277
601294
601296
601297
601298
601299
601300
601301
601302
601303
601304
601316
601318
601319
601323
601328
601329
601330
601331
601332
601333
601334
601336
601337
601373
601377
601378
601379
601995
601996
601998
602003
602004
602005
602006
602007
602009
602010
602011
602012
602013
602014
602015
602016
602021
602023
602024
602025
602026
602027
602028
602029
602030
602031
602038
602039
602046
602048
602050
602057
602058
602059
602060
602071
602072
602073
602074
602075
602076
602077
602078
602079
602080
602081
602082
602083
602084
602086
602087
602088
602089
602090
602097
602103
602104
602106
602107
602108
602109
602114
602115
602116
602117
602118
602119
602120
602121
602122
602123
602124
602125
602126
602127
602128
602129
602130
602132
602133
602134
602135
602136
602146
602147
602149
602153
602154
602155
602165
602175
602176
602177
602178
602179
602180
602181
602182
602183
602184
602185
602186
602207
602208
602209
602210
602211
602213
602214
602216
602217
602218
602219
602220
602221
602222
602231
602287
602288
602289
602291
602303
602305
602307
602308
602309
602310
602311
602312
602313
602314
602315
602316
602317
602318
602319
602320
602321
602322
602323
602324
602325
602326
602327
602328
602329
602330
602331
602332
602333
602334
602335
602336
602337
602338
602340
602341
602342
602343
602345
602346
602347
602348
602349
602350
602351
602352
602353
602354
602355
602356
602357
602358
602359
602360
602363
602364
602365
602366
602367
602368
602369
602370
602371
602372
602376
602379
602380
602383
602385
602386
602393
602394
602395
602396
602397
602398
602399
602400
602401
602402
602403
602404
602405
602406
602407
602408
602409
602410
602411
602412
602413
602414
602415
602416
602417
602418
602419
602420
602421
602422
602423
602424
602425
602426
602427
602429
602430
602431
602435
602437
602457
602458
602459
602460
602461
602462
602463
602464
602465
602466
602467
602468
602469
602470
602471
602472
602473
602474
602475
602476
602477
602478
602479
602480
602481
602482
602483
602495
602496
602497
602504
602510
602511
602520
602521
602522
602523
602524
602525
602526
602527
602528
602529
602537
602652
602658
602682
602688
602689
602690
602691
602698
602749
602761
602762
602764
602767
602770
602771
602772
602773
602787
602791
602792
602812
602825
602826
602827
602831
602832
602833
602834
602835
602842
602850
602851
602853
602854
602855
602856
602857
602866
602867
602868
602870
602871
602874
602893
602894
602895
602912
602913
602914
602915
602916
602917
602918
602920
602921
602922
602939
602940
602941
602942
602943
602944
602945
602946
602947
602948
602949
602950
602951
602952
602953
602954
602955
602956
602957
602958
602959
602960
602961
602962
602963
602964
602965
602966
602967
602968
602969
602970
602971
602972
602973
602974
602975
602976
602977
602978
602979
602981
602982
602983
602984
602985
602986
602987
602988
602989
602990
602991
602992
602993
602994
602995
602996
602997
602998
602

Create XML String In VB
What is the best way to create an XML string in VB? I want this string to contain a list of selected users along with their respective departments and categories to be reported upon. This string will be used to generate a Crystal Report with a SQL Server back end. I already have the stored procedure written to accept an XML string parameter.

Ideas?

Create A String From DB
Hi -

I have previously in other threads mentioned needing help creating a string amongst many other things. I am still stuck on this. How can I get a string of Names from my Access DB called everything...

Please give me an example

rbgerman

Please Help! Create String With Wildcards
Hello all! Thanks in advance for reading, and for any help.
First of all, I am using word 2000 and its version of vba.

I need to create a string that is a combination of
a fixed string of digits, an underscore and 3 random digits...
This string needs to find and insert a file from a windows directory
to my word doc.
The file name convention is: "12345678992_001.jpg"
The "12345678992_" section is static BUT the "001" suffix is random.
The files could be named "12345678992_001", "12345678992_002",
"12345678992_003", "12345678992_004" and so on...
heres a code example:
....
part_one = "12345678992"
search_file_name = part_one + "_001" + ".JPG"

What can I put in place of hardcoding "_001" in order for the string to return any file with that suffix????
It would need to return 12345678992_001 and/ 12345678992_002 etc

I tried something like:

search_file_name = part_one + "[0-9]{3}" + ".jpg"

but this did not work. I thought the wildcards like this were the
answer, but it seems to just include them literally like
12345678992_[0-9]{3}.jpg"

thanks!!!

John

Can You Create A Random String?
I searched the forums, but didn't find what I was looking for. Can you create a random string (alpha-numeric) say 60 characters in length?

Create Directory From String
Hi, I want to prompt the user for a name to be used to create a directory. I have a problem getting the MkDir command recognise the input string, Am I using the worng command? or advise on code required, please help me

Create File From String
Sorry if this has been covered berfore, I've had a search through the forums and not found anything. I'm using Access 97 and was wondering if there's any way of taking a string in a field and creating a file from it, ie g:DevelopmentFolderFile is the string and g:DevelopmentFolder is a diretory that already exists and it will create a file called "file" in this directory.

Thanks

Create String At Runtime?
I want my program to create some strings at runtime.
For example how can I create five strings at runtime ?

Create New Object From String
Hi
Sorry this is a cross post (thread707-1491214: Create new object from VBComponent).
Basically,
I have a list of classes and I want to create a new object from a user selected variable
CODEPrivate downloadFile As ISQL

Private Sub cboSelectList_Change()
Set downloadFile = cboSelectList.Text*

*Do something with this!!!!
End Sub


Please Help! How Do I Create An Image File (.bmp, .jpg Any Will Do!) Out Of A String?
Hello all

I am working on a project which requires me to build an image from the following:

the data provider sends the information for an

"image is sent as multiple strings, each string consists of up to 512 characters, where 'each character pair represents a byte in the .img file. Each character value
will be "A" + the value of each nibble (4 bits)"

(Enclosed in quotes cause it's the provider's description, not mine)

Can anyone give me advice on how to take this string data and convert into an image file format such as .jpg, etc.

Many, many thanks to anyone who can help!

Create HTML - String Problem??
I'm using the following Function code to create an HTML page:

Function FormatHTML() As String
Dim myHTML As String
myHTML = "<HTML><H2><center><font color=Blue><b>Daily Operations Status Report</b></font></h2></html>"
myHTML = myHTML & "<body><h3 align=left><font color=red><u><b>Critical Application Cycle End Times</b></font></u></h3>"
myHTML = myHTML & "<h3 align=left>&nbsp;&nbsp<b>Insurance</b></h3>"
myHTML = myHTML & "<p align=left>&nbsp;&nbsp;&nbsp;&nbsp;&bull;<b>Insurance DataBase (Critical Path - BT30004) ended at: " & htmlBT4 & "</b></p>"
myHTML = myHTML & "<p align=left>&nbsp;&nbsp;&nbsp;&nbsp;" & htmlMVS & "</p>"
End If
myHTML = myHTML & "</body></html>"
FormatHTML = myHTML
End Function


I call the function(FormatHTML) in an Outlook routine which works great. The problem is the last variable called: htmlMVS. When I do a debug.print htmlMVS it displays as multiple lines of text, example:
bt30004->bt50001
is00075
hi30004->hi50001

But, when I open the email web page it displays like this:
bt30004->bt50001 is00075 hi30004->hi50001

It's all in one line of text. I need it to display as the user enters it in the textbox which is in multiple lines and the debug statement confirms that. I parse the textbox and replace vbCrLf with vertical tab, that way I don't display control or line feed characters. I hope someone has an idea for me to try.

Rich

Create String To Be Line Of Code?
I don't know if this is how I want to accomplish this or not. A simple example of what I'd like to do is this:


Code:
tempString = "Msgbox " & """" & "This is a test" & """"

'Down here I want to run the string I've created as a line of code.
Is there any way to do this?

The real reason I want to do this is because I have the following line of code I am running to set some email addresses for a user in active directory:


Code:
contact1.putex 2, "proxyAddresses", Array("X400:c=US;a= ;p=Sigma Financial;o=Exchange;s=Contact;g=New;", "SMTP:ncontact@sigmarep.com")
The s=Contact;g=New and ncontact@sigmarep.com are going to be different every time I run the program. I have tried all combinations of just creating the custom information and putting it into that line of code, but it is never happy. I tried the following:


Code:
'Break parts of array up into strings and insert those in the statement
tempString1 = "X400:c=US;a= ;p=Sigma Financial;o=Exchange;s=" & lName & ";g=" & fName & ";"
tempString2 = "SMTP:" & eMail
contact1.putex 2, "proxyAddresses", Array(tempString1, tempString2)

'Make entire Array statement into string and insert that
tempString = "Array(" & """" & "X400:c=US;a= ;p=Sigma Financial;o=Exchange;s=" & lName & ";g=" & fName & ";" & """" & ", " & """" & "SMTP:ncontact@sigmarep.com" & """" & ")"
contact1.putex 2, "proxyAddresses", tempString

'Make actual Array of information and use that
var(0) = "X400:c=US;a= ;p=Sigma Financial;o=Exchange;s=" & lName & ";g=" & fName & ";"
var(1) = "SMTP:" & eMail
contact1.putex 2, "proxyAddresses", var

'And I tried just putting it all into one big line, but could never make VB happy with where the quote were.
Does anyone see any other ways for me to get the custom information into this line of code, or does anyone know a way to execute a string as a line of code? Thanks.

/<evin

Use String Addition To Create SELECT WHERE
I am trying to get information from a selected recordset in an Access 2000 database. The following code finds the correct recordset:


Code:
Dim MyConn As ADODB.Connection
Dim rs As ADODB.Recordset, strQuerySQL As String
Dim DMtxt As String, Slect As String
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:SAMSDATACOEDPLU.mdb;"
MyConn.Open

Slect = "SELECT * FROM EngineDMTBL WHERE DM='DM80C11D3'"
Set rs = MyConn.Execute(Slect)


But, I do not want to hard code in the DM value. I will be using a function with the DMtxt (see below) in the Function call. To debug the method, I tried to modify the last two lines:


Code:
DMtxt = "DM80C11D3"
Slect="""SELECT * FROM EngineDMTBL WHERE DM='"&DMtxt&"' """
Set rs = MyConn.Execute(Slect)
I keep getting errors like Expected end of statement or compile error on the Slect line.

I believe that the error is caused by adding strings that contain the comment indicator >> '.

The EngineDMTBL looks like this:
DM RPM1RPM2
DM8001 8001000
DM8001038011001
DM80C11D310001100
DM80C11E310021102

I would appreciate any help or references to this kind of string addition.

I have attached the VB6 files as .txt. (Note that I opened a worksheet from within VB for writing the results for debug purposes.)

Regards,

Might Be Simple ... But Not To Me {create String With " In It}
I'm trying to make a command spit out an html script. Is this possible?

scipt.text = "<html><script language = "Javascript">...

I keep getting errors with the due to some key words such as function and language and not to mention the "" everywhere in the script. Is there anyway I can get this going?

Thanks in advance.

BTW: I am not a programmer. Just playing with VB since I learned it in HS

Copyright © 2005-08 www.BigResource.com, All rights reserved