473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Images

EdB
We are having an odd problem saving images. We capture customer signatures
on a Palm Pilot and save them as points on a graph. We are able to
reconstruct these points to display the signature, but when we attempt to
save the file off so that we can pass it back to our customers we get an odd
result. If we try to view the file using Windows Picture and Fax viewer,
everything's ok. But try to view it using any other graphics program (such
as Paint or even as thumbnails in Windows Explorer) and we get nothing but a
black box. I have another app (JASC Image Commander) that tells me that the
file is not a valid JPG or BMP file (we tried both). Here's a sample of the
code.

SignatureManager is a DLL that is used to plot the points and reconstruct
the image. As I said, it displays just fine in the Picture Box on the form.

Dim SigMan As ASTSignature.SignatureManager
picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)),
Bitmap)

picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

imgSignature.Save(sFileName)

Anyone have any thoughts?

Nov 21 '05 #1
14 1425
Hi, EdB,

When you save, you should specify what format you are going to save
to....

imgSignature.Save(sFileName, System.Drawing.Imaging.ImageFormat.jpeg)
or
imgSignature.Save(sFileName, System.Drawing.Imaging.ImageFormat.bmp)

then see if you can open it.

HTH,
Barry

On Sun, 29 May 2005 19:08:03 -0700, EdB
<Ed*@discussions.microsoft.com> wrote:
We are having an odd problem saving images. We capture customer signatures
on a Palm Pilot and save them as points on a graph. We are able to
reconstruct these points to display the signature, but when we attempt to
save the file off so that we can pass it back to our customers we get an odd
result. If we try to view the file using Windows Picture and Fax viewer,
everything's ok. But try to view it using any other graphics program (such
as Paint or even as thumbnails in Windows Explorer) and we get nothing but a
black box. I have another app (JASC Image Commander) that tells me that the
file is not a valid JPG or BMP file (we tried both). Here's a sample of the
code.

SignatureManager is a DLL that is used to plot the points and reconstruct
the image. As I said, it displays just fine in the Picture Box on the form.

Dim SigMan As ASTSignature.SignatureManager
picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)),
Bitmap)

picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

imgSignature.Save(sFileName)

Anyone have any thoughts?


bceggersATcomcastDOTnet
Nov 21 '05 #2
EdB
Thanks, but that did not make a difference. I had had that in there, put it
back as you suggested and it didn't help. Infact, now even the Windows
Picture and Fax Viewer doesn't recognize it.

"Barry" wrote:
Hi, EdB,

When you save, you should specify what format you are going to save
to....

imgSignature.Save(sFileName, System.Drawing.Imaging.ImageFormat.jpeg)
or
imgSignature.Save(sFileName, System.Drawing.Imaging.ImageFormat.bmp)

then see if you can open it.

HTH,
Barry

On Sun, 29 May 2005 19:08:03 -0700, EdB
<Ed*@discussions.microsoft.com> wrote:
We are having an odd problem saving images. We capture customer signatures
on a Palm Pilot and save them as points on a graph. We are able to
reconstruct these points to display the signature, but when we attempt to
save the file off so that we can pass it back to our customers we get an odd
result. If we try to view the file using Windows Picture and Fax viewer,
everything's ok. But try to view it using any other graphics program (such
as Paint or even as thumbnails in Windows Explorer) and we get nothing but a
black box. I have another app (JASC Image Commander) that tells me that the
file is not a valid JPG or BMP file (we tried both). Here's a sample of the
code.

SignatureManager is a DLL that is used to plot the points and reconstruct
the image. As I said, it displays just fine in the Picture Box on the form.

Dim SigMan As ASTSignature.SignatureManager
picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)),
Bitmap)

picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

imgSignature.Save(sFileName)

Anyone have any thoughts?


bceggersATcomcastDOTnet

Nov 21 '05 #3
EdB,

I would look in the encoding class, every sample about it on MSDN is almost
in C# in my opininon is not that clear as I would like it. Can be that I
know nothing or less about graphics on a computer.

http://msdn.microsoft.com/library/de...classtopic.asp

Otherwise maybe these pages

Http://www.bobpowell.net/
Cor
Nov 21 '05 #4

"EdB" <Ed*@discussions.microsoft.com> wrote
We are having an odd problem saving images. Dim imgSignature As New System.Drawing.Bitmap(320, 138, Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)

picSignature.Image = imgSignature

Anyone have any thoughts?

It seems a bit strange that you would create a bitmap, asign it to a variable, and
then assign a different bitmap to that same variable. I would have thought that
section should look more like:

Dim imgSignature As Bitmap = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)
picSignature.Image = imgSignature.Clone
None the less, see if using the Clone method will help....

LFS

Nov 21 '05 #5
When creating a new 32bpp image the default values in the pixel array are
transparent black. This is interpreted in the picturebox as fully
transparent so you're probably seeing the signature just fine because its
projected over the back-colour of the picturebox. When this is saved all the
image transparency will be lost unless you save to PNG so you'll just see
what is apparently a black image..

Try setting the bitmap to white when you create it like this:
Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
Dim g as Graphics.FromImage(imgSignature)
g.Clear(Color.White)
g.Dispose()

'continue with the rest of your stuff here...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
We are having an odd problem saving images. We capture customer
signatures
on a Palm Pilot and save them as points on a graph. We are able to
reconstruct these points to display the signature, but when we attempt to
save the file off so that we can pass it back to our customers we get an
odd
result. If we try to view the file using Windows Picture and Fax viewer,
everything's ok. But try to view it using any other graphics program
(such
as Paint or even as thumbnails in Windows Explorer) and we get nothing but
a
black box. I have another app (JASC Image Commander) that tells me that
the
file is not a valid JPG or BMP file (we tried both). Here's a sample of
the
code.

SignatureManager is a DLL that is used to plot the points and reconstruct
the image. As I said, it displays just fine in the Picture Box on the
form.

Dim SigMan As ASTSignature.SignatureManager
picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)),
Bitmap)

picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

imgSignature.Save(sFileName)

Anyone have any thoughts?

Nov 21 '05 #6
EdB
Larry,

Thanks for the reply, but I still get "Invalid Bitmap" on the resulting files.

"Larry Serflaten" wrote:

"EdB" <Ed*@discussions.microsoft.com> wrote
We are having an odd problem saving images.

Dim imgSignature As New System.Drawing.Bitmap(320, 138, Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)

picSignature.Image = imgSignature

Anyone have any thoughts?

It seems a bit strange that you would create a bitmap, asign it to a variable, and
then assign a different bitmap to that same variable. I would have thought that
section should look more like:

Dim imgSignature As Bitmap = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)
picSignature.Image = imgSignature.Clone
None the less, see if using the Clone method will help....

LFS

Nov 21 '05 #7
EdB
Bob,

Thanks for the response.

When I tried this I got a compile error on this line:

Dim g as Graphics.FromImage(imgSignature)

The error says:

Array Bounds Cannot Appear In Type Specifiers
"Bob Powell [MVP]" wrote:
When creating a new 32bpp image the default values in the pixel array are
transparent black. This is interpreted in the picturebox as fully
transparent so you're probably seeing the signature just fine because its
projected over the back-colour of the picturebox. When this is saved all the
image transparency will be lost unless you save to PNG so you'll just see
what is apparently a black image..

Try setting the bitmap to white when you create it like this:
Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
Dim g as Graphics.FromImage(imgSignature)
g.Clear(Color.White)
g.Dispose()

'continue with the rest of your stuff here...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
We are having an odd problem saving images. We capture customer
signatures
on a Palm Pilot and save them as points on a graph. We are able to
reconstruct these points to display the signature, but when we attempt to
save the file off so that we can pass it back to our customers we get an
odd
result. If we try to view the file using Windows Picture and Fax viewer,
everything's ok. But try to view it using any other graphics program
(such
as Paint or even as thumbnails in Windows Explorer) and we get nothing but
a
black box. I have another app (JASC Image Commander) that tells me that
the
file is not a valid JPG or BMP file (we tried both). Here's a sample of
the
code.

SignatureManager is a DLL that is used to plot the points and reconstruct
the image. As I said, it displays just fine in the Picture Box on the
form.

Dim SigMan As ASTSignature.SignatureManager
picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)),
Bitmap)

picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

imgSignature.Save(sFileName)

Anyone have any thoughts?


Nov 21 '05 #8

"EdB" <Ed*@discussions.microsoft.com> wrote
Larry,

Thanks for the reply, but I still get "Invalid Bitmap" on the resulting files.


If you've tried declaring the format when you save, and you've tried using
a clone, I'd suggest the next thing is to try to copy the image from your
picturebox to another bitmap.

If you can copy it to another bitmap, you certainly should be able to save it.

Something is amiss, unfortunately you are the one who has to find it... :-P

LFS
Nov 21 '05 #9
EdB
I figured this out. This

Dim g as Graphics.FromImage(imgSignature)

needs to be

Dim g as Graphics = Graphics.FromImage(imgSignature)

But still, no joy.

"EdB" wrote:
Bob,

Thanks for the response.

When I tried this I got a compile error on this line:

Dim g as Graphics.FromImage(imgSignature)

The error says:

Array Bounds Cannot Appear In Type Specifiers
"Bob Powell [MVP]" wrote:
When creating a new 32bpp image the default values in the pixel array are
transparent black. This is interpreted in the picturebox as fully
transparent so you're probably seeing the signature just fine because its
projected over the back-colour of the picturebox. When this is saved all the
image transparency will be lost unless you save to PNG so you'll just see
what is apparently a black image..

Try setting the bitmap to white when you create it like this:
Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
Dim g as Graphics.FromImage(imgSignature)
g.Clear(Color.White)
g.Dispose()

'continue with the rest of your stuff here...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
We are having an odd problem saving images. We capture customer
signatures
on a Palm Pilot and save them as points on a graph. We are able to
reconstruct these points to display the signature, but when we attempt to
save the file off so that we can pass it back to our customers we get an
odd
result. If we try to view the file using Windows Picture and Fax viewer,
everything's ok. But try to view it using any other graphics program
(such
as Paint or even as thumbnails in Windows Explorer) and we get nothing but
a
black box. I have another app (JASC Image Commander) that tells me that
the
file is not a valid JPG or BMP file (we tried both). Here's a sample of
the
code.

SignatureManager is a DLL that is used to plot the points and reconstruct
the image. As I said, it displays just fine in the Picture Box on the
form.

Dim SigMan As ASTSignature.SignatureManager
picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)),
Bitmap)

picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

imgSignature.Save(sFileName)

Anyone have any thoughts?


Nov 21 '05 #10
Do you mean no joy as in the image is still black? There must be something
weird going on. Can you post a more comprehensive chunk of code?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
I figured this out. This

Dim g as Graphics.FromImage(imgSignature)

needs to be

Dim g as Graphics = Graphics.FromImage(imgSignature)

But still, no joy.

"EdB" wrote:
Bob,

Thanks for the response.

When I tried this I got a compile error on this line:

Dim g as Graphics.FromImage(imgSignature)

The error says:

Array Bounds Cannot Appear In Type Specifiers
"Bob Powell [MVP]" wrote:
> When creating a new 32bpp image the default values in the pixel array
> are
> transparent black. This is interpreted in the picturebox as fully
> transparent so you're probably seeing the signature just fine because
> its
> projected over the back-colour of the picturebox. When this is saved
> all the
> image transparency will be lost unless you save to PNG so you'll just
> see
> what is apparently a black image..
>
> Try setting the bitmap to white when you create it like this:
> Dim imgSignature As New System.Drawing.Bitmap(320, 138,
> Imaging.PixelFormat.Format32bppArgb)
> Dim g as Graphics.FromImage(imgSignature)
> g.Clear(Color.White)
> g.Dispose()
>
> 'continue with the rest of your stuff here...
>
>
>
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "EdB" <Ed*@discussions.microsoft.com> wrote in message
> news:2E**********************************@microsof t.com...
> > We are having an odd problem saving images. We capture customer
> > signatures
> > on a Palm Pilot and save them as points on a graph. We are able to
> > reconstruct these points to display the signature, but when we
> > attempt to
> > save the file off so that we can pass it back to our customers we get
> > an
> > odd
> > result. If we try to view the file using Windows Picture and Fax
> > viewer,
> > everything's ok. But try to view it using any other graphics program
> > (such
> > as Paint or even as thumbnails in Windows Explorer) and we get
> > nothing but
> > a
> > black box. I have another app (JASC Image Commander) that tells me
> > that
> > the
> > file is not a valid JPG or BMP file (we tried both). Here's a sample
> > of
> > the
> > code.
> >
> > SignatureManager is a DLL that is used to plot the points and
> > reconstruct
> > the image. As I said, it displays just fine in the Picture Box on
> > the
> > form.
> >
> > Dim SigMan As ASTSignature.SignatureManager
> > picSignature.SizeMode =
> > PictureBoxSizeMode.StretchImage
> >
> > Dim imgSignature As New System.Drawing.Bitmap(320,
> > 138,
> > Imaging.PixelFormat.Format32bppArgb)
> > imgSignature =
> > CType(SigMan.GetSignature(CStr(iDSID)),
> > Bitmap)
> >
> > picSignature.Image = imgSignature
> > picSignature.ClientSize = New Size(208, 72)
> >
> > imgSignature.Save(sFileName)
> >
> > Anyone have any thoughts?
> >
>
>
>

Nov 21 '05 #11
EdB
Ask and you shall receive:
#Step 1 - obtain Record ID
Dim iDSID As Int32 = DailyStop.GetDailyStopID(sLocationID, strSigTerminal,
strPullDate, strSigTime)
#Step 2 - Create resulting file name
Dim sFileName As String = "D:\CardinalSigs\" & CStr(iDSID) & ".bmp"

Try
#Step 3 - Signatures are based on locations, could be multiple
# packages per location, only gen the signature once
h.Add(CStr(iDSID), iDSID)

#Step 4 - Declare SigMan

Dim SigMan As ASTSignature.SignatureManager

picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(imgSignature)
g.Clear(Color.White)
g.Dispose()

#Step 5 = Build the signature (Code below)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)

#Step 6 - Assign image (This displays the sig)
picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

#Step 7 - Save the image
imgSignature.Save(sFileName)

Catch ex As Exception
'Do Nothing
End Try
#########GET SIGNATURE CODE

Public Shared Function GetSignature(ByVal StopID As String, Optional
ByVal Messages As Boolean = False) As System.Drawing.Image
Dim Result As System.Drawing.Bitmap

Dim ImageForSignatures As System.Drawing.Bitmap
Dim g As System.Drawing.Graphics
Dim blackPen As System.Drawing.Pen = New
System.Drawing.Pen(System.Drawing.Color.Black)

Dim intX As Integer = 0
Dim intY As Integer = 0
Dim intOX As Integer = 0
Dim intOY As Integer = 0
Dim startX As Integer = 1
Dim startY As Integer = 0
Dim lengthX As Integer = 0
Dim lengthY As Integer = 0
Dim nextComma As Integer = 0
Dim rawString As String = ""
Dim intStringLength As Integer = 0
Dim Position As Integer = 0
Try

Dim sqlConnection As New SqlConnection(myConnectionString)
sqlConnection.Open()
Dim sql1 As String = "Select ProcessDate, CourierID,
RouteNumberComplete, StopNumber From DailyStops Where ID = @ID"
Dim sql2 As String = "Select RawPoints From RawSignature Where
CourierID = @CID and Route = @RNC and StopNumber = @Num and ProcessDate = @PD"

Dim PD As DateTime
Dim CID As String = ""
Dim Route As String = ""
Dim Sequence As Integer = 0

Dim dr As SqlDataReader
Dim myCommand As New SqlCommand(sql1, sqlConnection)
myCommand.Parameters.Add("@ID", StopID)
dr = myCommand.ExecuteReader
dr.Read()
myCommand.Parameters.Clear()
PD = dr.GetDateTime(dr.GetOrdinal("ProcessDate"))
CID = dr.GetString(dr.GetOrdinal("CourierID"))
Route = dr.GetString(dr.GetOrdinal("RouteNumberComplete"))
Sequence = dr.GetInt32(dr.GetOrdinal("StopNumber"))
dr.Close()

myCommand.CommandText = sql2
myCommand.Parameters.Add("@RNC", Route)
myCommand.Parameters.Add("@CID", CID)
myCommand.Parameters.Add("@Num", Sequence)
myCommand.Parameters.Add("@PD", PD)
dr = myCommand.ExecuteReader
dr.Read()
blackPen.Width = 2
ImageForSignatures = New System.Drawing.Bitmap(320, 138,
Drawing.Imaging.PixelFormat.Format32bppArgb)
g = g.FromImage(ImageForSignatures)

'Parse the string
rawString = dr.GetString(dr.GetOrdinal("RawPoints"))
intStringLength = rawString.Length

While Position < intStringLength
Try
'startX = 0
nextComma = InStr(startX, rawString, ",")

lengthX = nextComma - startX

intX = CInt(rawString.Substring(startX - 1, lengthX))

startY = nextComma + 1

nextComma = InStr(startY, rawString, ",")
If nextComma = 0 Then
nextComma = rawString.Length + 1
End If
lengthY = nextComma - startY

intY = CInt(rawString.Substring(startY - 1, lengthY))

startX = nextComma + 2

Position = startX

If (intX <> intOX Or intY <> intOY) And (intOX <> 0 And
intOY <> 0) Then
'Draw the points out of the string
DrawPoints(intX, intY, intOX, intOY, blackPen, g)
End If

intOX = intX

intOY = intY

Catch e As Exception
Dim str As String = e.Message
Position = intStringLength + 1
End Try

End While

g.DrawImage(ImageForSignatures, New System.Drawing.Point(0, 0))
Result = ImageForSignatures
ImageForSignatures.Save("D:\CardinalSigs\" + StopID + ".jpg")
g.Dispose()

Catch e As Exception
Result = New Bitmap("D:\Signature\NoSig.jpg")
If Messages Then
Throw e 'MsgBox(e.Message)
End If
End Try

Return Result
End Function

"Bob Powell [MVP]" wrote:
Do you mean no joy as in the image is still black? There must be something
weird going on. Can you post a more comprehensive chunk of code?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
I figured this out. This

Dim g as Graphics.FromImage(imgSignature)

needs to be

Dim g as Graphics = Graphics.FromImage(imgSignature)

But still, no joy.

"EdB" wrote:
Bob,

Thanks for the response.

When I tried this I got a compile error on this line:

Dim g as Graphics.FromImage(imgSignature)

The error says:

Array Bounds Cannot Appear In Type Specifiers
"Bob Powell [MVP]" wrote:

> When creating a new 32bpp image the default values in the pixel array
> are
> transparent black. This is interpreted in the picturebox as fully
> transparent so you're probably seeing the signature just fine because
> its
> projected over the back-colour of the picturebox. When this is saved
> all the
> image transparency will be lost unless you save to PNG so you'll just
> see
> what is apparently a black image..
>
> Try setting the bitmap to white when you create it like this:
> Dim imgSignature As New System.Drawing.Bitmap(320, 138,
> Imaging.PixelFormat.Format32bppArgb)
> Dim g as Graphics.FromImage(imgSignature)
> g.Clear(Color.White)
> g.Dispose()
>
> 'continue with the rest of your stuff here...
>
>
>
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "EdB" <Ed*@discussions.microsoft.com> wrote in message
> news:2E**********************************@microsof t.com...
> > We are having an odd problem saving images. We capture customer
> > signatures
> > on a Palm Pilot and save them as points on a graph. We are able to
> > reconstruct these points to display the signature, but when we
> > attempt to
> > save the file off so that we can pass it back to our customers we get
> > an
> > odd
> > result. If we try to view the file using Windows Picture and Fax
> > viewer,
> > everything's ok. But try to view it using any other graphics program
> > (such
> > as Paint or even as thumbnails in Windows Explorer) and we get
> > nothing but
> > a
> > black box. I have another app (JASC Image Commander) that tells me
> > that
> > the
> > file is not a valid JPG or BMP file (we tried both). Here's a sample
> > of
> > the
> > code.
> >
> > SignatureManager is a DLL that is used to plot the points and
> > reconstruct
> > the image. As I said, it displays just fine in the Picture Box on
> > the
> > form.
> >
> > Dim SigMan As ASTSignature.SignatureManager
> > picSignature.SizeMode =
> > PictureBoxSizeMode.StretchImage
> >
> > Dim imgSignature As New System.Drawing.Bitmap(320,
> > 138,
> > Imaging.PixelFormat.Format32bppArgb)
> > imgSignature =
> > CType(SigMan.GetSignature(CStr(iDSID)),
> > Bitmap)
> >
> > picSignature.Image = imgSignature
> > picSignature.ClientSize = New Size(208, 72)
> >
> > imgSignature.Save(sFileName)
> >
> > Anyone have any thoughts?
> >
>
>
>


Nov 21 '05 #12
But you're still saving the file without specifying an image format. Saving
to a filename without specifying saves it in raw format. Use the line...

imgSignature.Save(sFileName,ImageFormat.Jpeg) 'or png or gif or
whatever......
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
Ask and you shall receive:
#Step 1 - obtain Record ID
Dim iDSID As Int32 = DailyStop.GetDailyStopID(sLocationID, strSigTerminal,
strPullDate, strSigTime)
#Step 2 - Create resulting file name
Dim sFileName As String = "D:\CardinalSigs\" & CStr(iDSID) & ".bmp"

Try
#Step 3 - Signatures are based on locations, could be multiple
# packages per location, only gen the signature once
h.Add(CStr(iDSID), iDSID)

#Step 4 - Declare SigMan

Dim SigMan As ASTSignature.SignatureManager

picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(imgSignature)
g.Clear(Color.White)
g.Dispose()

#Step 5 = Build the signature (Code below)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)

#Step 6 - Assign image (This displays the sig)
picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

#Step 7 - Save the image
imgSignature.Save(sFileName)

Catch ex As Exception
'Do Nothing
End Try
#########GET SIGNATURE CODE

Public Shared Function GetSignature(ByVal StopID As String, Optional
ByVal Messages As Boolean = False) As System.Drawing.Image
Dim Result As System.Drawing.Bitmap

Dim ImageForSignatures As System.Drawing.Bitmap
Dim g As System.Drawing.Graphics
Dim blackPen As System.Drawing.Pen = New
System.Drawing.Pen(System.Drawing.Color.Black)

Dim intX As Integer = 0
Dim intY As Integer = 0
Dim intOX As Integer = 0
Dim intOY As Integer = 0
Dim startX As Integer = 1
Dim startY As Integer = 0
Dim lengthX As Integer = 0
Dim lengthY As Integer = 0
Dim nextComma As Integer = 0
Dim rawString As String = ""
Dim intStringLength As Integer = 0
Dim Position As Integer = 0
Try

Dim sqlConnection As New SqlConnection(myConnectionString)
sqlConnection.Open()
Dim sql1 As String = "Select ProcessDate, CourierID,
RouteNumberComplete, StopNumber From DailyStops Where ID = @ID"
Dim sql2 As String = "Select RawPoints From RawSignature Where
CourierID = @CID and Route = @RNC and StopNumber = @Num and ProcessDate =
@PD"

Dim PD As DateTime
Dim CID As String = ""
Dim Route As String = ""
Dim Sequence As Integer = 0

Dim dr As SqlDataReader
Dim myCommand As New SqlCommand(sql1, sqlConnection)
myCommand.Parameters.Add("@ID", StopID)
dr = myCommand.ExecuteReader
dr.Read()
myCommand.Parameters.Clear()
PD = dr.GetDateTime(dr.GetOrdinal("ProcessDate"))
CID = dr.GetString(dr.GetOrdinal("CourierID"))
Route = dr.GetString(dr.GetOrdinal("RouteNumberComplete"))
Sequence = dr.GetInt32(dr.GetOrdinal("StopNumber"))
dr.Close()

myCommand.CommandText = sql2
myCommand.Parameters.Add("@RNC", Route)
myCommand.Parameters.Add("@CID", CID)
myCommand.Parameters.Add("@Num", Sequence)
myCommand.Parameters.Add("@PD", PD)
dr = myCommand.ExecuteReader
dr.Read()
blackPen.Width = 2
ImageForSignatures = New System.Drawing.Bitmap(320, 138,
Drawing.Imaging.PixelFormat.Format32bppArgb)
g = g.FromImage(ImageForSignatures)

'Parse the string
rawString = dr.GetString(dr.GetOrdinal("RawPoints"))
intStringLength = rawString.Length

While Position < intStringLength
Try
'startX = 0
nextComma = InStr(startX, rawString, ",")

lengthX = nextComma - startX

intX = CInt(rawString.Substring(startX - 1, lengthX))

startY = nextComma + 1

nextComma = InStr(startY, rawString, ",")
If nextComma = 0 Then
nextComma = rawString.Length + 1
End If
lengthY = nextComma - startY

intY = CInt(rawString.Substring(startY - 1, lengthY))

startX = nextComma + 2

Position = startX

If (intX <> intOX Or intY <> intOY) And (intOX <> 0 And
intOY <> 0) Then
'Draw the points out of the string
DrawPoints(intX, intY, intOX, intOY, blackPen, g)
End If

intOX = intX

intOY = intY

Catch e As Exception
Dim str As String = e.Message
Position = intStringLength + 1
End Try

End While

g.DrawImage(ImageForSignatures, New System.Drawing.Point(0, 0))
Result = ImageForSignatures
ImageForSignatures.Save("D:\CardinalSigs\" + StopID + ".jpg")
g.Dispose()

Catch e As Exception
Result = New Bitmap("D:\Signature\NoSig.jpg")
If Messages Then
Throw e 'MsgBox(e.Message)
End If
End Try

Return Result
End Function

"Bob Powell [MVP]" wrote:
Do you mean no joy as in the image is still black? There must be
something
weird going on. Can you post a more comprehensive chunk of code?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
>I figured this out. This
>
> Dim g as Graphics.FromImage(imgSignature)
>
> needs to be
>
> Dim g as Graphics = Graphics.FromImage(imgSignature)
>
> But still, no joy.
>
> "EdB" wrote:
>
>> Bob,
>>
>> Thanks for the response.
>>
>> When I tried this I got a compile error on this line:
>>
>> Dim g as Graphics.FromImage(imgSignature)
>>
>> The error says:
>>
>> Array Bounds Cannot Appear In Type Specifiers
>>
>>
>> "Bob Powell [MVP]" wrote:
>>
>> > When creating a new 32bpp image the default values in the pixel
>> > array
>> > are
>> > transparent black. This is interpreted in the picturebox as fully
>> > transparent so you're probably seeing the signature just fine
>> > because
>> > its
>> > projected over the back-colour of the picturebox. When this is saved
>> > all the
>> > image transparency will be lost unless you save to PNG so you'll
>> > just
>> > see
>> > what is apparently a black image..
>> >
>> > Try setting the bitmap to white when you create it like this:
>> > Dim imgSignature As New System.Drawing.Bitmap(320, 138,
>> > Imaging.PixelFormat.Format32bppArgb)
>> > Dim g as Graphics.FromImage(imgSignature)
>> > g.Clear(Color.White)
>> > g.Dispose()
>> >
>> > 'continue with the rest of your stuff here...
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Bob Powell [MVP]
>> > Visual C#, System.Drawing
>> >
>> > Find great Windows Forms articles in Windows Forms Tips and Tricks
>> > http://www.bobpowell.net/tipstricks.htm
>> >
>> > Answer those GDI+ questions with the GDI+ FAQ
>> > http://www.bobpowell.net/faqmain.htm
>> >
>> > All new articles provide code in C# and VB.NET.
>> > Subscribe to the RSS feeds provided and never miss a new article.
>> >
>> >
>> >
>> >
>> >
>> > "EdB" <Ed*@discussions.microsoft.com> wrote in message
>> > news:2E**********************************@microsof t.com...
>> > > We are having an odd problem saving images. We capture customer
>> > > signatures
>> > > on a Palm Pilot and save them as points on a graph. We are able
>> > > to
>> > > reconstruct these points to display the signature, but when we
>> > > attempt to
>> > > save the file off so that we can pass it back to our customers we
>> > > get
>> > > an
>> > > odd
>> > > result. If we try to view the file using Windows Picture and Fax
>> > > viewer,
>> > > everything's ok. But try to view it using any other graphics
>> > > program
>> > > (such
>> > > as Paint or even as thumbnails in Windows Explorer) and we get
>> > > nothing but
>> > > a
>> > > black box. I have another app (JASC Image Commander) that tells
>> > > me
>> > > that
>> > > the
>> > > file is not a valid JPG or BMP file (we tried both). Here's a
>> > > sample
>> > > of
>> > > the
>> > > code.
>> > >
>> > > SignatureManager is a DLL that is used to plot the points and
>> > > reconstruct
>> > > the image. As I said, it displays just fine in the Picture Box on
>> > > the
>> > > form.
>> > >
>> > > Dim SigMan As ASTSignature.SignatureManager
>> > > picSignature.SizeMode =
>> > > PictureBoxSizeMode.StretchImage
>> > >
>> > > Dim imgSignature As New
>> > > System.Drawing.Bitmap(320,
>> > > 138,
>> > > Imaging.PixelFormat.Format32bppArgb)
>> > > imgSignature =
>> > > CType(SigMan.GetSignature(CStr(iDSID)),
>> > > Bitmap)
>> > >
>> > > picSignature.Image = imgSignature
>> > > picSignature.ClientSize = New Size(208, 72)
>> > >
>> > > imgSignature.Save(sFileName)
>> > >
>> > > Anyone have any thoughts?
>> > >
>> >
>> >
>> >


Nov 21 '05 #13
EdB
.....and that still yields me a black rectangle.

I really need to figure out if this is a VB.Net bug or something we're
doing. Would you entertain the idea of taking this off line? I would be
willing to pay a fee for your time. I would like to give you access to the
computer that this is being done on and have you look at it directly. Is
that possible?

"Bob Powell [MVP]" wrote:
But you're still saving the file without specifying an image format. Saving
to a filename without specifying saves it in raw format. Use the line...

imgSignature.Save(sFileName,ImageFormat.Jpeg) 'or png or gif or
whatever......
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
Ask and you shall receive:
#Step 1 - obtain Record ID
Dim iDSID As Int32 = DailyStop.GetDailyStopID(sLocationID, strSigTerminal,
strPullDate, strSigTime)
#Step 2 - Create resulting file name
Dim sFileName As String = "D:\CardinalSigs\" & CStr(iDSID) & ".bmp"

Try
#Step 3 - Signatures are based on locations, could be multiple
# packages per location, only gen the signature once
h.Add(CStr(iDSID), iDSID)

#Step 4 - Declare SigMan

Dim SigMan As ASTSignature.SignatureManager

picSignature.SizeMode = PictureBoxSizeMode.StretchImage

Dim imgSignature As New System.Drawing.Bitmap(320, 138,
Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(imgSignature)
g.Clear(Color.White)
g.Dispose()

#Step 5 = Build the signature (Code below)
imgSignature = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)

#Step 6 - Assign image (This displays the sig)
picSignature.Image = imgSignature
picSignature.ClientSize = New Size(208, 72)

#Step 7 - Save the image
imgSignature.Save(sFileName)

Catch ex As Exception
'Do Nothing
End Try
#########GET SIGNATURE CODE

Public Shared Function GetSignature(ByVal StopID As String, Optional
ByVal Messages As Boolean = False) As System.Drawing.Image
Dim Result As System.Drawing.Bitmap

Dim ImageForSignatures As System.Drawing.Bitmap
Dim g As System.Drawing.Graphics
Dim blackPen As System.Drawing.Pen = New
System.Drawing.Pen(System.Drawing.Color.Black)

Dim intX As Integer = 0
Dim intY As Integer = 0
Dim intOX As Integer = 0
Dim intOY As Integer = 0
Dim startX As Integer = 1
Dim startY As Integer = 0
Dim lengthX As Integer = 0
Dim lengthY As Integer = 0
Dim nextComma As Integer = 0
Dim rawString As String = ""
Dim intStringLength As Integer = 0
Dim Position As Integer = 0
Try

Dim sqlConnection As New SqlConnection(myConnectionString)
sqlConnection.Open()
Dim sql1 As String = "Select ProcessDate, CourierID,
RouteNumberComplete, StopNumber From DailyStops Where ID = @ID"
Dim sql2 As String = "Select RawPoints From RawSignature Where
CourierID = @CID and Route = @RNC and StopNumber = @Num and ProcessDate =
@PD"

Dim PD As DateTime
Dim CID As String = ""
Dim Route As String = ""
Dim Sequence As Integer = 0

Dim dr As SqlDataReader
Dim myCommand As New SqlCommand(sql1, sqlConnection)
myCommand.Parameters.Add("@ID", StopID)
dr = myCommand.ExecuteReader
dr.Read()
myCommand.Parameters.Clear()
PD = dr.GetDateTime(dr.GetOrdinal("ProcessDate"))
CID = dr.GetString(dr.GetOrdinal("CourierID"))
Route = dr.GetString(dr.GetOrdinal("RouteNumberComplete"))
Sequence = dr.GetInt32(dr.GetOrdinal("StopNumber"))
dr.Close()

myCommand.CommandText = sql2
myCommand.Parameters.Add("@RNC", Route)
myCommand.Parameters.Add("@CID", CID)
myCommand.Parameters.Add("@Num", Sequence)
myCommand.Parameters.Add("@PD", PD)
dr = myCommand.ExecuteReader
dr.Read()
blackPen.Width = 2
ImageForSignatures = New System.Drawing.Bitmap(320, 138,
Drawing.Imaging.PixelFormat.Format32bppArgb)
g = g.FromImage(ImageForSignatures)

'Parse the string
rawString = dr.GetString(dr.GetOrdinal("RawPoints"))
intStringLength = rawString.Length

While Position < intStringLength
Try
'startX = 0
nextComma = InStr(startX, rawString, ",")

lengthX = nextComma - startX

intX = CInt(rawString.Substring(startX - 1, lengthX))

startY = nextComma + 1

nextComma = InStr(startY, rawString, ",")
If nextComma = 0 Then
nextComma = rawString.Length + 1
End If
lengthY = nextComma - startY

intY = CInt(rawString.Substring(startY - 1, lengthY))

startX = nextComma + 2

Position = startX

If (intX <> intOX Or intY <> intOY) And (intOX <> 0 And
intOY <> 0) Then
'Draw the points out of the string
DrawPoints(intX, intY, intOX, intOY, blackPen, g)
End If

intOX = intX

intOY = intY

Catch e As Exception
Dim str As String = e.Message
Position = intStringLength + 1
End Try

End While

g.DrawImage(ImageForSignatures, New System.Drawing.Point(0, 0))
Result = ImageForSignatures
ImageForSignatures.Save("D:\CardinalSigs\" + StopID + ".jpg")
g.Dispose()

Catch e As Exception
Result = New Bitmap("D:\Signature\NoSig.jpg")
If Messages Then
Throw e 'MsgBox(e.Message)
End If
End Try

Return Result
End Function

"Bob Powell [MVP]" wrote:
Do you mean no joy as in the image is still black? There must be
something
weird going on. Can you post a more comprehensive chunk of code?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:00**********************************@microsof t.com...
>I figured this out. This
>
> Dim g as Graphics.FromImage(imgSignature)
>
> needs to be
>
> Dim g as Graphics = Graphics.FromImage(imgSignature)
>
> But still, no joy.
>
> "EdB" wrote:
>
>> Bob,
>>
>> Thanks for the response.
>>
>> When I tried this I got a compile error on this line:
>>
>> Dim g as Graphics.FromImage(imgSignature)
>>
>> The error says:
>>
>> Array Bounds Cannot Appear In Type Specifiers
>>
>>
>> "Bob Powell [MVP]" wrote:
>>
>> > When creating a new 32bpp image the default values in the pixel
>> > array
>> > are
>> > transparent black. This is interpreted in the picturebox as fully
>> > transparent so you're probably seeing the signature just fine
>> > because
>> > its
>> > projected over the back-colour of the picturebox. When this is saved
>> > all the
>> > image transparency will be lost unless you save to PNG so you'll
>> > just
>> > see
>> > what is apparently a black image..
>> >
>> > Try setting the bitmap to white when you create it like this:
>> > Dim imgSignature As New System.Drawing.Bitmap(320, 138,
>> > Imaging.PixelFormat.Format32bppArgb)
>> > Dim g as Graphics.FromImage(imgSignature)
>> > g.Clear(Color.White)
>> > g.Dispose()
>> >
>> > 'continue with the rest of your stuff here...
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Bob Powell [MVP]
>> > Visual C#, System.Drawing
>> >
>> > Find great Windows Forms articles in Windows Forms Tips and Tricks
>> > http://www.bobpowell.net/tipstricks.htm
>> >
>> > Answer those GDI+ questions with the GDI+ FAQ
>> > http://www.bobpowell.net/faqmain.htm
>> >
>> > All new articles provide code in C# and VB.NET.
>> > Subscribe to the RSS feeds provided and never miss a new article.
>> >
>> >
>> >
>> >
>> >
>> > "EdB" <Ed*@discussions.microsoft.com> wrote in message
>> > news:2E**********************************@microsof t.com...
>> > > We are having an odd problem saving images. We capture customer
>> > > signatures
>> > > on a Palm Pilot and save them as points on a graph. We are able
>> > > to
>> > > reconstruct these points to display the signature, but when we
>> > > attempt to
>> > > save the file off so that we can pass it back to our customers we
>> > > get
>> > > an
>> > > odd
>> > > result. If we try to view the file using Windows Picture and Fax
>> > > viewer,

Nov 21 '05 #14
Just remove the spamkiller from my email address and contact me.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
....and that still yields me a black rectangle.

I really need to figure out if this is a VB.Net bug or something we're
doing. Would you entertain the idea of taking this off line? I would be
willing to pay a fee for your time. I would like to give you access to
the
computer that this is being done on and have you look at it directly. Is
that possible?

"Bob Powell [MVP]" wrote:
But you're still saving the file without specifying an image format.
Saving
to a filename without specifying saves it in raw format. Use the line...

imgSignature.Save(sFileName,ImageFormat.Jpeg) 'or png or gif or
whatever......
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"EdB" <Ed*@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
> Ask and you shall receive:
>
>
> #Step 1 - obtain Record ID
> Dim iDSID As Int32 = DailyStop.GetDailyStopID(sLocationID,
> strSigTerminal,
> strPullDate, strSigTime)
> #Step 2 - Create resulting file name
> Dim sFileName As String = "D:\CardinalSigs\" & CStr(iDSID) & ".bmp"
>
> Try
> #Step 3 - Signatures are based on locations, could be multiple
> # packages per location, only gen the signature once
> h.Add(CStr(iDSID), iDSID)
>
> #Step 4 - Declare SigMan
>
> Dim SigMan As ASTSignature.SignatureManager
>
> picSignature.SizeMode = PictureBoxSizeMode.StretchImage
>
> Dim imgSignature As New System.Drawing.Bitmap(320, 138,
> Imaging.PixelFormat.Format32bppArgb)
> Dim g As Graphics = Graphics.FromImage(imgSignature)
> g.Clear(Color.White)
> g.Dispose()
>
> #Step 5 = Build the signature (Code below)
> imgSignature = CType(SigMan.GetSignature(CStr(iDSID)), Bitmap)
>
> #Step 6 - Assign image (This displays the sig)
> picSignature.Image = imgSignature
> picSignature.ClientSize = New Size(208, 72)
>
> #Step 7 - Save the image
> imgSignature.Save(sFileName)
>
> Catch ex As Exception
> 'Do Nothing
> End Try
>
>
> #########GET SIGNATURE CODE
>
> Public Shared Function GetSignature(ByVal StopID As String, Optional
> ByVal Messages As Boolean = False) As System.Drawing.Image
> Dim Result As System.Drawing.Bitmap
>
> Dim ImageForSignatures As System.Drawing.Bitmap
> Dim g As System.Drawing.Graphics
> Dim blackPen As System.Drawing.Pen = New
> System.Drawing.Pen(System.Drawing.Color.Black)
>
> Dim intX As Integer = 0
> Dim intY As Integer = 0
> Dim intOX As Integer = 0
> Dim intOY As Integer = 0
> Dim startX As Integer = 1
> Dim startY As Integer = 0
> Dim lengthX As Integer = 0
> Dim lengthY As Integer = 0
> Dim nextComma As Integer = 0
> Dim rawString As String = ""
> Dim intStringLength As Integer = 0
> Dim Position As Integer = 0
> Try
>
> Dim sqlConnection As New SqlConnection(myConnectionString)
> sqlConnection.Open()
> Dim sql1 As String = "Select ProcessDate, CourierID,
> RouteNumberComplete, StopNumber From DailyStops Where ID = @ID"
> Dim sql2 As String = "Select RawPoints From RawSignature
> Where
> CourierID = @CID and Route = @RNC and StopNumber = @Num and ProcessDate
> =
> @PD"
>
> Dim PD As DateTime
> Dim CID As String = ""
> Dim Route As String = ""
> Dim Sequence As Integer = 0
>
> Dim dr As SqlDataReader
> Dim myCommand As New SqlCommand(sql1, sqlConnection)
> myCommand.Parameters.Add("@ID", StopID)
> dr = myCommand.ExecuteReader
> dr.Read()
> myCommand.Parameters.Clear()
> PD = dr.GetDateTime(dr.GetOrdinal("ProcessDate"))
> CID = dr.GetString(dr.GetOrdinal("CourierID"))
> Route = dr.GetString(dr.GetOrdinal("RouteNumberComplete"))
> Sequence = dr.GetInt32(dr.GetOrdinal("StopNumber"))
> dr.Close()
>
> myCommand.CommandText = sql2
> myCommand.Parameters.Add("@RNC", Route)
> myCommand.Parameters.Add("@CID", CID)
> myCommand.Parameters.Add("@Num", Sequence)
> myCommand.Parameters.Add("@PD", PD)
> dr = myCommand.ExecuteReader
> dr.Read()
> blackPen.Width = 2
> ImageForSignatures = New System.Drawing.Bitmap(320, 138,
> Drawing.Imaging.PixelFormat.Format32bppArgb)
> g = g.FromImage(ImageForSignatures)
>
> 'Parse the string
> rawString = dr.GetString(dr.GetOrdinal("RawPoints"))
> intStringLength = rawString.Length
>
> While Position < intStringLength
> Try
> 'startX = 0
> nextComma = InStr(startX, rawString, ",")
>
> lengthX = nextComma - startX
>
> intX = CInt(rawString.Substring(startX - 1,
> lengthX))
>
> startY = nextComma + 1
>
> nextComma = InStr(startY, rawString, ",")
> If nextComma = 0 Then
> nextComma = rawString.Length + 1
> End If
> lengthY = nextComma - startY
>
> intY = CInt(rawString.Substring(startY - 1,
> lengthY))
>
> startX = nextComma + 2
>
> Position = startX
>
> If (intX <> intOX Or intY <> intOY) And (intOX <> 0
> And
> intOY <> 0) Then
> 'Draw the points out of the string
> DrawPoints(intX, intY, intOX, intOY, blackPen,
> g)
> End If
>
> intOX = intX
>
> intOY = intY
>
> Catch e As Exception
> Dim str As String = e.Message
> Position = intStringLength + 1
> End Try
>
> End While
>
> g.DrawImage(ImageForSignatures, New System.Drawing.Point(0,
> 0))
> Result = ImageForSignatures
> ImageForSignatures.Save("D:\CardinalSigs\" + StopID +
> ".jpg")
> g.Dispose()
>
> Catch e As Exception
> Result = New Bitmap("D:\Signature\NoSig.jpg")
> If Messages Then
> Throw e 'MsgBox(e.Message)
> End If
> End Try
>
> Return Result
> End Function
>
>
>
> "Bob Powell [MVP]" wrote:
>
>> Do you mean no joy as in the image is still black? There must be
>> something
>> weird going on. Can you post a more comprehensive chunk of code?
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>> http://www.bobpowell.net/tipstricks.htm
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>> http://www.bobpowell.net/faqmain.htm
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> "EdB" <Ed*@discussions.microsoft.com> wrote in message
>> news:00**********************************@microsof t.com...
>> >I figured this out. This
>> >
>> > Dim g as Graphics.FromImage(imgSignature)
>> >
>> > needs to be
>> >
>> > Dim g as Graphics = Graphics.FromImage(imgSignature)
>> >
>> > But still, no joy.
>> >
>> > "EdB" wrote:
>> >
>> >> Bob,
>> >>
>> >> Thanks for the response.
>> >>
>> >> When I tried this I got a compile error on this line:
>> >>
>> >> Dim g as Graphics.FromImage(imgSignature)
>> >>
>> >> The error says:
>> >>
>> >> Array Bounds Cannot Appear In Type Specifiers
>> >>
>> >>
>> >> "Bob Powell [MVP]" wrote:
>> >>
>> >> > When creating a new 32bpp image the default values in the pixel
>> >> > array
>> >> > are
>> >> > transparent black. This is interpreted in the picturebox as fully
>> >> > transparent so you're probably seeing the signature just fine
>> >> > because
>> >> > its
>> >> > projected over the back-colour of the picturebox. When this is
>> >> > saved
>> >> > all the
>> >> > image transparency will be lost unless you save to PNG so you'll
>> >> > just
>> >> > see
>> >> > what is apparently a black image..
>> >> >
>> >> > Try setting the bitmap to white when you create it like this:
>> >> > Dim imgSignature As New System.Drawing.Bitmap(320, 138,
>> >> > Imaging.PixelFormat.Format32bppArgb)
>> >> > Dim g as Graphics.FromImage(imgSignature)
>> >> > g.Clear(Color.White)
>> >> > g.Dispose()
>> >> >
>> >> > 'continue with the rest of your stuff here...
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Bob Powell [MVP]
>> >> > Visual C#, System.Drawing
>> >> >
>> >> > Find great Windows Forms articles in Windows Forms Tips and
>> >> > Tricks
>> >> > http://www.bobpowell.net/tipstricks.htm
>> >> >
>> >> > Answer those GDI+ questions with the GDI+ FAQ
>> >> > http://www.bobpowell.net/faqmain.htm
>> >> >
>> >> > All new articles provide code in C# and VB.NET.
>> >> > Subscribe to the RSS feeds provided and never miss a new article.
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > "EdB" <Ed*@discussions.microsoft.com> wrote in message
>> >> > news:2E**********************************@microsof t.com...
>> >> > > We are having an odd problem saving images. We capture
>> >> > > customer
>> >> > > signatures
>> >> > > on a Palm Pilot and save them as points on a graph. We are
>> >> > > able
>> >> > > to
>> >> > > reconstruct these points to display the signature, but when we
>> >> > > attempt to
>> >> > > save the file off so that we can pass it back to our customers
>> >> > > we
>> >> > > get
>> >> > > an
>> >> > > odd
>> >> > > result. If we try to view the file using Windows Picture and
>> >> > > Fax
>> >> > > viewer,

Nov 21 '05 #15

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

Similar topics

7
by: Wayne | last post by:
I have a script that uses filesystemobject that reads files from a given path, in my case images. It is running on a server that is 2000 adv svr w/ all current patches. The script prior to some...
3
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a...
10
by: Neo Geshel | last post by:
I am seeking to hand-roll my own blog in ASP.NET 2.0 and SQLExpress 2005. Why? Because I can. Because I will gain experience. The one thing that has me stumped at square one is inline images....
6
by: wattanabi | last post by:
Greetings, I'm attempting to layout a bunch of images in a grid using DIV's instead of a table. I currently have a 3x6 table that I need to convert to css. I've seen various example of a 3 to 4...
2
by: mouseit101 | last post by:
Hi, I'm writing a script that would (hopefully) search google images for whatever, and then return a list of URLs for the image. Right now I have: $dom = new DomDocument(); $url =...
0
by: Frenchie | last post by:
Hi, I have created a very neet menu from an example found on the MSDN library at: http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.menuitembinding.imageurlfield.aspx My...
1
by: Cerebral Believer | last post by:
Hi folks, I am using the following code for mouse over (roll-overs) in my XHTML code. <a onmouseover="document.getElementById('sitemap').src = '../images/buttons/sitemap_mo.jpg';"...
4
toxicpaint
by: toxicpaint | last post by:
Hi, can anyone give me a hand. I'm currently displaying 4 random images at the top of a page. I did this using an array of 35 pictures and then writing them to page. The problem I have is that in...
5
by: remon87 | last post by:
I need some help. I have javasript that creates the submenu but it works if I have a text with css. I need it to do the same with a roll over images. so when I click on the image the submenu...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...

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.