473,732 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.SetResoluti on(300, 200)


' Create a blank image.
img = New System.Drawing. Bitmap( _
intWidt + 15, _
intHeight + 20, _
System.Drawing. Imaging.PixelFo rmat.Format32bp pRgb _

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(By Val 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.PixelFo rmat.Format32bp pRgb _
' Create the canvas.
canvas = System.Drawing. Graphics.FromIm age(img)

' Paint a background.
canvas.Clear(Sy stem.Drawing.Co lor.White)

' Draw the string.
canvas.DrawStri ng( _
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.ImageFo rmat.Jpeg _
img.Save( _
"C:\Images\ " & strFileName & ".bmp", _
System.Drawing. Imaging.ImageFo rmat.Bmp _
' Cleanup.
If Not canvas Is Nothing Then
canvas.Dispose( )
End If
End Try

Return (Nothing)
End Function

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

Nov 17 '06 #1
0 997

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: funcSter | last post by:
Hey, got a prob which is driving me nuts! I'm trying to resize the resolution of an image as well as it's pyhsical byte size. I've got: byte bytImage = null; System.Drawing.Image imgImage = null; System.Drawing.Image imgNewImage = null;
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses the DLL above. Now the application, together with the above DLL’s is successfully loading a TIF image file (62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200 DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08...
by: James A Taber | last post by:
Problem resizing image.(JPG) If i try to resize an img with horisontal=150 and vertical resolution=150 The quality of the target image is dramatically reduced. Source code is provided below. How can i solve this? What am i doing wrong? Thanx in advance -James A Taber
by: neverstill | last post by:
hi- So I wrote this nice little page that will allow the managers to add images to the products table. Without too many details to confuse everything, basically what I'm doing is: getting an Image from there I'm creating a new Bitmap(Image, int w, int h); then I'm saving that bitmap various encoder quality values.
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full resolution (ie. large). I have a database that contains references to the pictures. Currently I have to resize the jpgs manually, and then point the ImageUrl property at that jpg using databinding. This works fine. I would like to avoid the resizing step...
by: Steve Lloyd | last post by:
Hi, I am stuck on how I can resize and image client side before it is uploaded to the server. Basically remote users take images using a digital camera and we need them to upload them to the server. Most people have there cameras set to high resolution so uploading in the image and resizing once on the server is not really an option and they do not want to (not capable of!) change the camera resolution.
by: Brian | last post by:
Using A2K I have an image control on a report and use code to set the image.picture to the required jpg. 3 of the jpgs resize properly but 2 do not - they display much smaller than the image control. The problem jpgs were originally created as line drawings in Word. They were then copy and pasted to Paint where they were saved as jpg files. Sizemode is set to stretch.(have tried clip and zoom but no better). I cannot find any way to...
by: Saaima | last post by:
Hi All when I store a picture of size 800*600 pixels in database (SqlServer) field Photo (Image) and load it into crystal report through query by dragging and dropping the field on report it appears well but as its size is too large and when i resize it its resolution become so wrong to can not see image. such as in Employee photo in Employee record Actually i need a passport size photo on report. So i save a picture of this size and get...
by: kombu67 | last post by:
I'm reading a series of images from a MS SQL table and saving them to directory. These are staff ID pictures from our security card app. Once I've extracted the ID photo from the security app to disk, I need to reference the disk file in our HR app. As part of the process, I'm resizing the image and changing its resolution from 96 to 72 dpi. If they are not at a 72 dpi resolution, the HR app freezes. The resizing works without a hitch, but...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.