469,902 Members | 2,007 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

Image resizing after resolution adjustment.

Hello all,

I am working with some barcode images using a TTF (True Type Font). I know
it is not the best method, but it is what I have available at the moment. I
have everything working all up to printing the barcode to an image file, I
have code that works for that but the resolution is far too low for
recognition from a barcode scanner

The form I have contains a textbox, label, and 2 buttons. The textbox is the
input section, label is the output, button1 is the convert event button2 is
the print function.

How it runs.

Enter text to convert and hit button1. Button1 coverts to proper a code39
barcode string, send string to label and change label font to code39.
Instant Barcode.

Hit button2 and pass to the function the labels string, PreferredWidth,
PreferredHeight, and FileName.

This creates 2 image files of the perfect size and they look decent, but with
too low a resolution to be read by a barcode scanner. I have attempted to
fix this by adding the code line:

img.SetResolution(300, 200)

after

' Create a blank image.
img = New System.Drawing.Bitmap( _
intWidt + 15, _
intHeight + 20, _
System.Drawing.Imaging.PixelFormat.Format32bppRgb _
)

But I cannot figure a way to resize the image to make it the right size like
the function without that code line in it. Does anyone have any ideas?

Current Image Function code prints a barcode(works but resolution too low).

Private Function Print_Images(ByVal strData As String, ByVal strFont As
String, ByVal intWidth As Integer, ByVal intHeight As Integer, ByVal
strFileName As String)
Dim img As System.Drawing.Bitmap
Dim canvas As System.Drawing.Graphics = Nothing

' Create a blank image.
img = New System.Drawing.Bitmap( _
intWidt + 15, _
intHeight + 20, _
System.Drawing.Imaging.PixelFormat.Format32bppRgb _
)
Try
' Create the canvas.
canvas = System.Drawing.Graphics.FromImage(img)

' Paint a background.
canvas.Clear(System.Drawing.Color.White)

' Draw the string.
canvas.DrawString( _
strData, _
New System.Drawing.Font(strFont, 28), _
System.Drawing.Brushes.Black, _
10, _
10 _
)

' Save the image to disk.
img.Save( _
"C:\Images\" & strFileName & ".jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg _
)
img.Save( _
"C:\Images\" & strFileName & ".bmp", _
System.Drawing.Imaging.ImageFormat.Bmp _
)
Finally
' Cleanup.
If Not canvas Is Nothing Then
canvas.Dispose()
End If
img.Dispose()
End Try

Return (Nothing)
End Function

--
Message posted via http://www.dotnetmonster.com

Nov 17 '06 #1
0 860

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by funcSter | last post: by
4 posts views Thread by James A Taber | last post: by
6 posts views Thread by neverstill | last post: by
10 posts views Thread by David W. Simmonds | last post: by
1 post views Thread by Steve Lloyd | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.