hi
this is hardik
i m having problem in saving an image
i m working on .net platform using visual studio 2008
i m using a picture box and when i m trying to save that image it'showing me the following error "the generic error occured in GDI+" i m not getting wht to do
how to save the image that is been displayed in the picture box
kindly help
thank you
kimiraikkonen wrote:
Re: ImageCodecInfo and array's references
13-Jan-08
(e-mail address removed)..
Teemu
Thanks for the link, however I have already done saving image wit
specify quality / compression, even it was too hard to find out
needed to get and search for help on 3rd party VB sites. However th
issue you pointed out "compression" is off-topic i think, i jus
wanted to pay attention to which GetImageEncoders() array member
refers to which image type.
Previous Posts In This Thread:
Re: ImageCodecInfo and array's references
I don't think there is a guaranteed order of the codecs. However, you may
want to check the MIME type associated with the codec
<URL:
http://google.com/groups?selm=#[email protected]
--
M S Herfried K. Wagne
M V P <URL:
http://dotnet.mvps.org/
V B <URL:
http://dotnet.mvps.org/dotnet/faqs/>
Re: ImageCodecInfo and array's references
Could thi
http://msdn2.microsoft.com/en-us/library/bb882583.asp
example be useful for you
-Teemu
Re: ImageCodecInfo and array's references
"kimiraikkonen" <
[email protected]> kirjoitti viestiss?
I know that you weren't looking for compression settings. The example I gave
contained also a nice method to get the right encoder, did you look at it
Dim jgpEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg
Private Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInf
Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders(
Dim codec As ImageCodecInf
For Each codec In codec
If codec.FormatID = format.Guid The
Return code
End I
Next code
Return Nothin
End Functio
Solution was quite similar to Herfried's code
-Teemu
ImageCodecInfo and array's references
Hi
In order to save image file with some additional encoder parameters
you need to us
System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders() array t
specify with image codec you want to use
I searched MSDN or other sites with no info, but i found out by tryin
that GetImageEncoder() array refers different image formats. Here ar
them
GetImageEncoders(0) : Bitmap, BM
GetImageEncoders(1) : JPE
GetImageEncoders(2): GI
GetImageEncoders(3): TIF
GetImageEncoders(4): PN
that's all. And does someone approve this? Or is it a kind of thin
that array references can be found by self-trial of developer
Only found this MSDN link with no enumarating array items
http://msdn2.microsoft.com/en-us/library/system.drawing.imaging.imagecodecinfo.getimageencoders.asp
Thanks...
Re: ImageCodecInfo and array's references
(e-mail address removed)..
Teemu
Thanks for the link, however I have already done saving image wit
specify quality / compression, even it was too hard to find out
needed to get and search for help on 3rd party VB sites. However th
issue you pointed out "compression" is off-topic i think, i jus
wanted to pay attention to which GetImageEncoders() array member
refers to which image type.
Did you look at this sample?
Did you look at this sample? I'd like to know if it solved your problem.
-Teemu
Re: ImageCodecInfo and array's references
"kimiraikkonen" <
[email protected]> kirjoitti viestiss?
I didn't write it. It is directly from MSDN Arcticle you said to be
off-topic...
When you search the right encoder using GetEncoder-function you have to know
the type of image. So it's quite easy to add the right extension to file
name.
-Teemu
Re: ImageCodecInfo and array's references
"Teemu" <
[email protected]> kirjoitti viestiss?
And of course this is possible:
Dim jgpEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)
Dim FileExtension As String = jgpEncoder.FilenameExtension
See
http://msdn2.microsoft.com/en-us/li...imaging.imagecodecinfo.filenameextension.aspx
-Teemu
Re: ImageCodecInfo and array's references
Dim FileExtension As String =
jgpEncoder.FilenameExtension.Split(";").Replace("*","")
-Teemu
Re: ImageCodecInfo and array's references
Sorry, this is the right code:
Dim FileExtension As String = _
jgpEncoder.FilenameExtension.Split(";")(0).Replace("*","")
-Teemu
Re: ImageCodecInfo and array's references
That depends on you. If that works fine I do not see any reason why not to
use it.
It would also be possible to find all encoders and add them to save dialog
with correct extensions.
-Teemu
Re: ImageCodecInfo and array's references
(e-mail address removed)...
fo
However after spending some time to understand you code
1- Why did you have to write the function as a class library-like?
2-ImageCodecInfo is OK, but encoder parameters are missing which is
required to save the image. However i configured that part as:
Dim eps As Imaging.EncoderParameters =3D New
Imaging.EncoderParameters(1)
eps.Param(0) =3D New
Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality,
<value>)
3-After i change the codec to any codec (like gif or BMP) i want my
image to save with the codec's extension. I mean, an image can be
saved in jpg extension but actually its codec is a bmp or gif, that's
possible.
And it's OK.
Thanks
Re: ImageCodecInfo and array's references
(e-mail address removed)...
..
But this format is not proper for saving files like "myfilename" +
FileExtension. FilenameExtension property returns non-formatted string
as a general type of codec like *.gif for GIF files, *.Jpeg *.Jpe
*.Jpg etc. I want only one valid extension to be saved with my file:
eg: "myfilename" + extension where "extension" must be ".jpg" for jpeg
files for example.
Re: ImageCodecInfo and array's references
(e-mail address removed)...
'Replace' is not a member of 'System.Array error happened.
Re: ImageCodecInfo and array's references
(e-mail address removed)...
Thanks that worked, however i wanted to manipulate same thing while
saving the image through a save file dialog control. I made something
which saves my image file with the desired filter extension of
saveFileDialog control's:
Try
If savedlg.ShowDialog =3D Windows.Forms.DialogResult.OK Then
If savedlg.FilterIndex =3D 1 Then
PictureBox1.Image.Save(savedlg.FileName,
System.Drawing.Imaging.ImageFormat.Jpeg)
ElseIf savedlg.FilterIndex =3D 2 Then
PictureBox1.Image.Save(savedlg.FileName,
System.Drawing.Imaging.ImageFormat.Gif)
ElseIf savedlg.FilterIndex =3D 3 Then
PictureBox1.Image.Save(savedlg.FileName,
System.Drawing.Imaging.ImageFormat.Bmp)
End If
which saves the files with the correct format + extension in my
savefileDialog (savedlg).
Is this a sufficent way or could be better to save a image file with
different image types shown on savefiledialog?
Thanks.
Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF GridView Sample To Insert, Update, and Delete Records
http://www.eggheadcafe.com/tutorial...a-c9a46fd3aeb2/wpf-gridview-sample-to-in.aspx