473,406 Members | 2,217 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,406 software developers and data experts.

Image.Save problem

I am getting an error message "Description: Value cannot be null.
Parameter name: encoder" when performing this instruction:
frmPicView.pic.Image.Save(ms, frmPicView.pic.Image.RawFormat)

Here is the code: what I am doing is scanning a document and try to
get it from the form where I am previewing it directly to the database

Private Sub PicTwainPro1_PostScandotNet(ByVal classPtr As Integer,
ByVal objID As Integer, ByVal Cancel As Boolean) Handles
PicTwainPro1.PostScandotNet

Const sFName As String = "PicTwainPro1_PostScandotNet"
Try
'PicTwainPro1.IResX = 304
'Me.pic1.Image = PicTwainPro1.Picture
Dim frmPicView As New frmPicView
frmPicView.Width = PicTwainPro1.IWidth
frmPicView.Height = PicTwainPro1.IHeight
frmPicView.pic.Width = PicTwainPro1.IWidth
frmPicView.pic.Height = PicTwainPro1.IHeight
frmPicView.Show()
frmPicView.pic.Image = PicTwainPro1.Picture
Application.DoEvents()
Cancel = False
PicTwainPro1.CloseSession()

Dim ms As New MemoryStream
frmPicView.pic.Image.Save(ms,
frmPicView.pic.Image.RawFormat) ' <-- Having the error here

Dim arrayImage() As Byte = ms.GetBuffer
ms.Close() ' Closes the Memory Stream

Dim m_DAL As dbHandler

If m_DAL Is Nothing Then
m_DAL = New dbHandler
End If

m_DAL.InsertLBAImage(IDRacines, IDLBABanque, arrayImage)

m_DAL = Nothing

Catch ex As Exception
MessageBox.Show(sFName + ": " + ex.Message, Me.Text,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Nov 20 '05 #1
2 2706
Hi,

You are using the image.save(stream, imageformat).
frmPicView.pic.Image.RawFormat is not a valid imageformat. Try this.
Dim ms As New System.IO.MemoryStream

PictureBox1.Image.Save(ms, ImageFormat.Bmp)

Ken
---------------------------

"Corobori" <jl****@corobori.com> wrote in message
news:3b**************************@posting.google.c om:
I am getting an error message "Description: Value cannot be null.
Parameter name: encoder" when performing this instruction:
frmPicView.pic.Image.Save(ms, frmPicView.pic.Image.RawFormat)

Here is the code: what I am doing is scanning a document and try to
get it from the form where I am previewing it directly to the database

Private Sub PicTwainPro1_PostScandotNet(ByVal classPtr As Integer,
ByVal objID As Integer, ByVal Cancel As Boolean) Handles
PicTwainPro1.PostScandotNet

Const sFName As String = "PicTwainPro1_PostScandotNet"
Try
'PicTwainPro1.IResX = 304
'Me.pic1.Image = PicTwainPro1.Picture
Dim frmPicView As New frmPicView
frmPicView.Width = PicTwainPro1.IWidth
frmPicView.Height = PicTwainPro1.IHeight
frmPicView.pic.Width = PicTwainPro1.IWidth
frmPicView.pic.Height = PicTwainPro1.IHeight
frmPicView.Show()
frmPicView.pic.Image = PicTwainPro1.Picture
Application.DoEvents()
Cancel = False
PicTwainPro1.CloseSession()

Dim ms As New MemoryStream
frmPicView.pic.Image.Save(ms,
frmPicView.pic.Image.RawFormat) ' <-- Having the error here

Dim arrayImage() As Byte = ms.GetBuffer
ms.Close() ' Closes the Memory Stream

Dim m_DAL As dbHandler

If m_DAL Is Nothing Then
m_DAL = New dbHandler
End If

m_DAL.InsertLBAImage(IDRacines, IDLBABanque, arrayImage)

m_DAL = Nothing

Catch ex As Exception
MessageBox.Show(sFName + ": " + ex.Message, Me.Text,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004
Nov 20 '05 #2
Thanks Ken, working now.
Nov 20 '05 #3

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

Similar topics

3
by: CanyonJ | last post by:
I've been running into a frustrating problem for a while now. I use image.FromStream to open a tif, then perform some drawstring methods, and then save the file again. The tiffs are in 1 bit per...
2
by: Programmer | last post by:
Hi all Here is my problem I want to create an image so i can pass it on an object to put it as watermark in my pdf report Here is what i have write so far Dim objBitmap As...
4
by: moondaddy | last post by:
Using vb.net I need to download image files to the client browser where they can save to disk. Below is some sample code I'm using. when I run this the File Download window in the browser says: ...
5
by: aarondouglas28 | last post by:
Hey all, I'm hoping someone can help me with a little problem I have. First a little background. I'm working on developing a site which displays live feeds from a security camera. The camera is...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
8
by: jbrewer | last post by:
I'm trying to read in a FITs image file for my research, and I decided that writing a file decoder for the Python imaging library would be the easiest way to accomplish this for my needs. FITs is...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
5
by: Steve | last post by:
Hi all Does anybody please know a way to extract an Image from a pdf file and save it as a TIFF? I have used a scanner to scan documents which are then placed on a server, but I need to...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...

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.