M
Mike Dole
I'm writing and reading EPS pictures in a dataset with the following 2
functions:
Public Function SavePhoto(ByVal MyfileName As String) As Boolean
Try
FotoResult = Nothing
If Len(MyfileName) > 0 Then
Dim fs As FileStream = New FileStream(MyfileName, _
FileMode.OpenOrCreate, FileAccess.Read,
FileShare.ReadWrite)
Dim rawData() As Byte = New Byte(fs.Length) {}
ReDim FotoResult(fs.Length)
fs.Read(rawData, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
FotoResult = rawData
SavePhoto = True
End If
Catch ex As System.Exception
MsgBox(ex.ToString)
SavePhoto = False
End Try
End Function
Public Sub GetPhoto(ByVal MyPhoto As String, ByVal MyPicBox As
PictureBox, ByVal MyRow As DataRow)
Try
Dim CurImage As Image = Nothing
If Not IsDBNull(MyRow(MyPhoto)) Then
Dim MyData() As Byte
MyData = MyRow(MyPhoto)
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream("c:\" & MyPhoto & ".eps", _
FileMode.Create, FileAccess.Write,
FileShare.ReadWrite)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
' Display image
CurImage = Image.FromFile("c:\" & MyPhoto & ".eps")
MyPicBox.Image = New Bitmap(CurImage)
MyPicBox.Invalidate()
'Object weer leegmaken
CurImage.Dispose()
CurImage = Nothing
Else
MyPicBox.Image = Nothing
End If
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
I've tried to use jpg at first because I can't hook an EPS file up to
a picturebox (It says so in the example, but it won't work..)
Anyway I can pick a EPS picture save it to a field in a datarow,
printout a cr.net report with a blob field with the EPS pic in it but:
The quality's no good... it almost looked better when I used the .jpg
files...
So at the moment I've got 2 problems:
- How can I improve the quality of the blob pictures on the report
- Along the way: does anybody know if I can use the imageconverter
object or something else to write the EPS to a filestream (like in the
function below) and use the file with a picturebox?
Thanks in advance,
Mike
functions:
Public Function SavePhoto(ByVal MyfileName As String) As Boolean
Try
FotoResult = Nothing
If Len(MyfileName) > 0 Then
Dim fs As FileStream = New FileStream(MyfileName, _
FileMode.OpenOrCreate, FileAccess.Read,
FileShare.ReadWrite)
Dim rawData() As Byte = New Byte(fs.Length) {}
ReDim FotoResult(fs.Length)
fs.Read(rawData, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
FotoResult = rawData
SavePhoto = True
End If
Catch ex As System.Exception
MsgBox(ex.ToString)
SavePhoto = False
End Try
End Function
Public Sub GetPhoto(ByVal MyPhoto As String, ByVal MyPicBox As
PictureBox, ByVal MyRow As DataRow)
Try
Dim CurImage As Image = Nothing
If Not IsDBNull(MyRow(MyPhoto)) Then
Dim MyData() As Byte
MyData = MyRow(MyPhoto)
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream("c:\" & MyPhoto & ".eps", _
FileMode.Create, FileAccess.Write,
FileShare.ReadWrite)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
' Display image
CurImage = Image.FromFile("c:\" & MyPhoto & ".eps")
MyPicBox.Image = New Bitmap(CurImage)
MyPicBox.Invalidate()
'Object weer leegmaken
CurImage.Dispose()
CurImage = Nothing
Else
MyPicBox.Image = Nothing
End If
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
I've tried to use jpg at first because I can't hook an EPS file up to
a picturebox (It says so in the example, but it won't work..)
Anyway I can pick a EPS picture save it to a field in a datarow,
printout a cr.net report with a blob field with the EPS pic in it but:
The quality's no good... it almost looked better when I used the .jpg
files...
So at the moment I've got 2 problems:
- How can I improve the quality of the blob pictures on the report
- Along the way: does anybody know if I can use the imageconverter
object or something else to write the EPS to a filestream (like in the
function below) and use the file with a picturebox?
Thanks in advance,
Mike