Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Reading ??

Status
Not open for further replies.

DannyB

Programmer
Mar 19, 2000
99
PT
Hi, I'm developing an image reader, and have to put the images in an SQL7 DB. I Can't read the image file !! this is the snippet :<br><br>&nbsp;&nbsp;iFile = FreeFile(5)<br>&nbsp;&nbsp;Open txtImagem.Text For Binary Access Read As iFile<br>&nbsp;&nbsp;Line Input #iFile, rAux<br>&nbsp;&nbsp;Debug.Print Len(rAux)<br>&nbsp;&nbsp;UpDateImage Val(txtKey.Text)<br>&nbsp;&nbsp;Close #iFile<br><br>Somehow the image is not well red, its only 4 bytes long instead of 200 or so. Any Ideas of what I could be doing wrong ?? <p> <br><a href=mailto: > </a><br><a href= </a><br>
 
Hi Danny,<br><br>Think you should be using <FONT FACE=monospace><b>Input</font></b> rather than <FONT FACE=monospace><b>Line Input</font></b>.<br><br><i>&quot;The Line Input # statement reads from a file one character at a time until it encounters a carriage return (Chr(13)) or carriage return–linefeed (Chr(13) + Chr(10)) sequence.&quot;</i> So <FONT FACE=monospace><b>Line Input</font></b> is for text files really. What's happening with your file is that <FONT FACE=monospace><b>Line Input</font></b> is reading up to what it thinks is the end of a line..... Not what you wanted really.<br><br>The <FONT FACE=monospace><b>Input</font></b> function might be more what you're looking for. The follwing example reads character data - but you could do the same with an array of <FONT FACE=monospace><b>Byte</font></b> for your binary image data.<br><br><FONT FACE=monospace><b><br>Dim MyBigString<br>Open &quot;TESTFILE&quot; For Input As #1&nbsp;&nbsp;&nbsp;' Open file.<br>Do While Not EOF(1)&nbsp;&nbsp;&nbsp;' Loop until end of file.<br>&nbsp;&nbsp;&nbsp;MyBigString = MyBigString & Input(1, #1)&nbsp;&nbsp;&nbsp;' Get one character at a time.<br>Loop<br>Close #1&nbsp;&nbsp;&nbsp;' Close file.<br></font></b><br><br><br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Please -- Don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
Thanks Mike, solved the problem with InputB, since it reads bytes, what i needed. Another thing that got solved was putting the graphic in an SQL field. Did it with Appendchunk. Finally I saw it through the browser, with ASP. The only thing now, is paging through the graphic files , checking the info, and loading them onto the DB.<br><br>Thanks once more Mike !! <p> <br><a href=mailto: > </a><br><a href= </a><br>
 
May I suggest a faster file read? The following changes to Mike's code will read the file in one operation.<br><br>Dim MyBigString as String<br>Open &quot;TESTFILE&quot; For Binary As #1&nbsp;&nbsp;&nbsp;' Open file.<br>MyBigString = String$(Lof(1), 0)<br>Get #1, , MyBigString<br>Close #1&nbsp;&nbsp;&nbsp;' Close file.<br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
not sure if this will help or not, might help you work with it if, you can save it to a Byte Array try using the command <br>LoadPicture() <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top