Shimi Weitzhandler

I want to create in my program a component\plag-in\control to have capability scanning files to *.tiff and also I want save them (as files) in my database and print them, everything whithin my program.

has nobody an answer




Re: Visual Basic Language How am I creating a scanning control?

Riquel Dong ¨C MSFT

Hi Shimi,

Based on your post, my understanding of your question is that you need to convert the text file to tiff file. We can take the following actions to achieve this.

1. Convert a text file to the image. Here is the code snippet to write the string to the image file.

Code Snippet

Dim FontName As String = "Courier New"

Dim FontColor As Color = Color.Black

Dim BackColor As Color = Color.White

Dim FontSize As Integer = 14

Dim Width As Integer = 25

Dim h As Single = (FontSize * 1.5F)

Dim Height As Integer = Integer.Parse(h.ToString())

Dim FileName As String = "c:\MyImage"

Dim objBrushForeColor As New SolidBrush(FontColor)

Dim objBrushBackColor As New SolidBrush(BackColor)

Dim objPoint As New Point(0, 2)

Dim objFont As New Font(FontName, FontSize)

Dim objBitmap As New Bitmap(Width, Height)

Dim objGraphics As Graphics = System.Drawing.Graphics.FromImage(objBitmap)

objGraphics.FillRectangle(objBrushBackColor, 0, 0, Width, (FontSize * 1.5F))

objGraphics.DrawString("this is my test", objFont, objBrushForeColor, objPoint)

objBitmap.Save(FileName + ".bmp", ImageFormat.Bmp)

2. Create the Tiff file. You can use some 3-rd party libraries to achieve this. Please search this from the web.

3. When you need to print the Tiff file, you can extract the seperate frame from Tiff image file. About how to print the image, please visit: Basic Text and Image Printing. Here is the code snippet to split the tiff image.

Code Snippet

Dim tif As New Bitmap("c:\billy.tiff")

Dim framenumber As Integer = tif.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page)

For x As Integer = 0 To framenumber - 1

tif.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, x)

Dim destimg As New Bitmap(tif.Width, tif.Height)

Dim gr As Graphics = Graphics.FromImage(destimg)

gr.DrawImage(tif, 0, 0)

destimg.Save("d:\temp\" + CStr(x + 1) + ".tif", System.Drawing.Imaging.ImageFormat.Tiff)

gr.Dispose()

destimg.Dispose()

Next

4. Save the image into database, please see this thread.

Best regards,

Riquel.






Re: Visual Basic Language How am I creating a scanning control?

Shimi Weitzhandler

your information was very useful, even so maybe I didn't make my self clear anough.

I want that in my program should be an option supplies access to a phisical scanning device.

then I want to scan documents and feed them into a database (I steel don't know how...), and also save theese scanned docs to the computers file system with a tiff\jpg extention (of course, I also don't know how you do this one),

also I want to make an opposite function, to read tiff\jpg files and feed them to the database (if an SQL database can contain a File datatype).

thanks, Shalom...






Re: Visual Basic Language How am I creating a scanning control?

nobugz

You'll have to use WIA to interface with your scanner. Start reading here...





Re: Visual Basic Language How am I creating a scanning control?

Shimi Weitzhandler

Great,thanks.






Re: Visual Basic Language How am I creating a scanning control?

Shimi Weitzhandler

I also wanted to know how can you store images in a database,

or, as a replacement, store in the database a binding value which leads to the image

thanks






Re: Visual Basic Language How am I creating a scanning control?

Riquel Dong ¨C MSFT

Hi Shimi,

Based on your post, you need to write and read the image from the database. The databases support the data types that accommodate very large objects like the image, known as BLOB or CLOB columns. You can handle the data of this type by using CommandType.SequentialAccess and the IDataReader.GetChars or IDataReader.GetBytes method in ADO.NET. Here are two articles about how to handle the large data columns. It should satisfy your requirements.

1. Writing BLOB Values to a Database. It adds employee information to the Employees table in the Northwind database. A photo of the employee is read from a file and added to the Photo field in the table, which is an image field.

2. Obtaining BLOB values from a database. This example returns the publisher id and logo from the pubs sample database in Microsoft SQL Server. The publisher id (pub_id) is a character field, and the logo is an image, which is a BLOB.

Best regards,

Riquel.






Re: Visual Basic Language How am I creating a scanning control?

Shimi Weitzhandler

theoretical, I understood what you said, I just don't know two things,

first, how can I get access to the 'Northwind' database (if it exists in my computer);

and second, I've never used the 'image' datatype in an SQL server datatype and therefor I don't know what it is made for.

many thanks

comment:

I don't have any SQL server semples, I'll be very happy knowing where can I find them (may even in my own computer)...