|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
problem in saving imagethis 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 On Jan 12, 4:15 pm, "Teemu" <tsir***@hotmail.com> wrote:
69ba-aeb0-4544-94f3-6423dc680***@v29g2000hsf.googlegroups.com...
Teemu,
Thanks for the link, however I have already done saving image with
specify quality / compression, even it was too hard to find out,
needed to get and search for help on 3rd party VB sites. However the
issue you pointed out "compression" is off-topic i think, i just
wanted to pay attention to which GetImageEncoders() array members
refers to which image type. Previous Posts In This Thread:On Saturday, January 12, 2008 7:59 AM Herfried K. Wagner [MVP] wrote: Re: ImageCodecInfo and array's references "kimiraikkonen" <kimiraikkone***@gmail.com> schrieb:
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=%23o1whuiqFHA.2480%40TK2MSFTNGP10.phx.gbl>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/> On Saturday, January 12, 2008 9:15 AMTeemu wrote: Re: ImageCodecInfo and array's references Could this http://msdn2.microsoft.com/en-us/library/bb882583.aspx example be useful for you? -Teemu On Saturday, January 12, 2008 12:11 PM Teemu wrote: Re: ImageCodecInfo and array's references "kimiraikkonen" <kimiraikkone***@gmail.com> kirjoitti viestiss?
news:501b5f52-6c26-4736-bd9c-f08c670a9e73@f47g2000hsd.googlegroups.com...
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 ImageCodecInfo
Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()
Dim codec As ImageCodecInfo
For Each codec In codecs
If codec.FormatID = format.Guid Then
Return codec
End If
Next codec
Return Nothing
End Function
Solution was quite similar to Herfried's code.
-Teemu On Sunday, January 13, 2008 1:53 AMkimiraikkonen wrote: ImageCodecInfo and array's references Hi, In order to save image file with some additional encoder parameters, you need to use System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders() array to specify with image codec you want to use. I searched MSDN or other sites with no info, but i found out by trying that GetImageEncoder() array refers different image formats. Here are them: GetImageEncoders(0) : Bitmap, BMP GetImageEncoders(1) : JPEG GetImageEncoders(2): GIF GetImageEncoders(3): TIFF GetImageEncoders(4): PNG that's all. And does someone approve this? Or is it a kind of thing 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.aspx Thanks... On Sunday, January 13, 2008 1:53 AM kimiraikkonen wrote: Re: ImageCodecInfo and array's references On Jan 12, 4:15 pm, "Teemu" <tsir***@hotmail.com> wrote:
69ba-aeb0-4544-94f3-6423dc680***@v29g2000hsf.googlegroups.com...
Teemu,
Thanks for the link, however I have already done saving image with
specify quality / compression, even it was too hard to find out,
needed to get and search for help on 3rd party VB sites. However the
issue you pointed out "compression" is off-topic i think, i just
wanted to pay attention to which GetImageEncoders() array members
refers to which image type. On Wednesday, January 16, 2008 6:54 AMTeemu wrote: Did you look at this sample? Did you look at this sample? I'd like to know if it solved your problem. -Teemu On Wednesday, January 16, 2008 9:19 AM Teemu wrote: Re: ImageCodecInfo and array's references "kimiraikkonen" <kimiraikkone***@gmail.com> kirjoitti viestiss?
news:074ef27a-f586-4349-a0e4-97dcb55d5e9d@x69g2000hsx.googlegroups.com...
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 On Wednesday, January 16, 2008 9:24 AMTeemu wrote: Re: ImageCodecInfo and array's references "Teemu" <tsir***@hotmail.com> kirjoitti viestiss?
news:Pnojj.281745$bU6.21014@reader1.news.saunalahti.fi...
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/library/system.drawing.imaging.imagecodecinfo.filenameextension.aspx
-Teemu On Wednesday, January 16, 2008 11:00 AMTeemu wrote: Re: ImageCodecInfo and array's references Dim FileExtension As String = jgpEncoder.FilenameExtension.Split(";").Replace("*","") -Teemu On Wednesday, January 16, 2008 11:04 AM Teemu wrote: Re: ImageCodecInfo and array's references Sorry, this is the right code: Dim FileExtension As String = _ jgpEncoder.FilenameExtension.Split(";")(0).Replace("*","") -Teemu On Wednesday, January 16, 2008 11:25 AM Teemu wrote: 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 On Thursday, January 17, 2008 5:30 AM kimiraikkonen wrote: Re: ImageCodecInfo and array's references On Jan 16, 1:54 pm, "Teemu" <tsir***@hotmail.com> wrote:
10***@reader1.news.saunalahti.fi...
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 On Thursday, January 17, 2008 5:30 AMkimiraikkonen wrote: Re: ImageCodecInfo and array's references On Jan 16, 4:24 pm, "Teemu" <tsir***@hotmail.com> wrote:
1***@reader1.news.saunalahti.fi...
..
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. On Thursday, January 17, 2008 5:30 AMkimiraikkonen wrote: Re: ImageCodecInfo and array's references e77f-7dd8-409f-b214-8a968da97***@k39g2000hsf.googlegroups.com... 'Replace' is not a member of 'System.Array error happened. On Thursday, January 17, 2008 5:30 AM kimiraikkonen wrote: Re: ImageCodecInfo and array's references On Jan 16, 6:04 pm, "Teemu" <tsir***@hotmail.com> wrote:
3***@reader1.news.saunalahti.fi...
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/tutorials/aspnet/fc9a5bf6-f5bb-4443-a92a-c9a46fd3aeb2/wpf-gridview-sample-to-in.aspx It needs one row of code so showing that cannot be that difficult?
"Hardik Patadia" wrote in message Show quoteHide quote news:201042114425fordownloadfromnet@yahoo.com... > 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 > > On Jan 12, 4:15 pm, "Teemu" <tsir***@hotmail.com> wrote: > 69ba-aeb0-4544-94f3-6423dc680***@v29g2000hsf.googlegroups.com... > > Teemu, > Thanks for the link, however I have already done saving image with > specify quality / compression, even it was too hard to find out, > needed to get and search for help on 3rd party VB sites. However the > issue you pointed out "compression" is off-topic i think, i just > wanted to pay attention to which GetImageEncoders() array members > refers to which image type. > > Previous Posts In This Thread: > > On Saturday, January 12, 2008 7:59 AM > Herfried K. Wagner [MVP] wrote: > > Re: ImageCodecInfo and array's references > "kimiraikkonen" <kimiraikkone***@gmail.com> schrieb: > > 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=%23o1whuiqFHA.2480%40TK2MSFTNGP10.phx.gbl> > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > > On Saturday, January 12, 2008 9:15 AM > Teemu wrote: > > Re: ImageCodecInfo and array's references > Could this > http://msdn2.microsoft.com/en-us/library/bb882583.aspx > example be useful for you? > > -Teemu > > On Saturday, January 12, 2008 12:11 PM > Teemu wrote: > > Re: ImageCodecInfo and array's references > "kimiraikkonen" <kimiraikkone***@gmail.com> kirjoitti viestiss? > news:501b5f52-6c26-4736-bd9c-f08c670a9e73@f47g2000hsd.googlegroups.com... > > > 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 ImageCodecInfo > > Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders() > > Dim codec As ImageCodecInfo > For Each codec In codecs > If codec.FormatID = format.Guid Then > Return codec > End If > Next codec > Return Nothing > > End Function > > > Solution was quite similar to Herfried's code. > > -Teemu > > On Sunday, January 13, 2008 1:53 AM > kimiraikkonen wrote: > > ImageCodecInfo and array's references > Hi, > In order to save image file with some additional encoder parameters, > you need to use > System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders() array to > specify with image codec you want to use. > > I searched MSDN or other sites with no info, but i found out by trying > that GetImageEncoder() array refers different image formats. Here are > them: > > GetImageEncoders(0) : Bitmap, BMP > GetImageEncoders(1) : JPEG > GetImageEncoders(2): GIF > GetImageEncoders(3): TIFF > GetImageEncoders(4): PNG > > that's all. And does someone approve this? Or is it a kind of thing > 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.aspx > > Thanks... > > On Sunday, January 13, 2008 1:53 AM > kimiraikkonen wrote: > > Re: ImageCodecInfo and array's references > On Jan 12, 4:15 pm, "Teemu" <tsir***@hotmail.com> wrote: > 69ba-aeb0-4544-94f3-6423dc680***@v29g2000hsf.googlegroups.com... > > Teemu, > Thanks for the link, however I have already done saving image with > specify quality / compression, even it was too hard to find out, > needed to get and search for help on 3rd party VB sites. However the > issue you pointed out "compression" is off-topic i think, i just > wanted to pay attention to which GetImageEncoders() array members > refers to which image type. > > On Wednesday, January 16, 2008 6:54 AM > Teemu wrote: > > Did you look at this sample? > Did you look at this sample? I'd like to know if it solved your problem. > > -Teemu > > On Wednesday, January 16, 2008 9:19 AM > Teemu wrote: > > Re: ImageCodecInfo and array's references > "kimiraikkonen" <kimiraikkone***@gmail.com> kirjoitti viestiss? > news:074ef27a-f586-4349-a0e4-97dcb55d5e9d@x69g2000hsx.googlegroups.com... > > > 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 > > On Wednesday, January 16, 2008 9:24 AM > Teemu wrote: > > Re: ImageCodecInfo and array's references > "Teemu" <tsir***@hotmail.com> kirjoitti viestiss? > news:Pnojj.281745$bU6.21014@reader1.news.saunalahti.fi... > > 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/library/system.drawing.imaging.imagecodecinfo.filenameextension.aspx > > -Teemu > > On Wednesday, January 16, 2008 11:00 AM > Teemu wrote: > > Re: ImageCodecInfo and array's references > Dim FileExtension As String = > jgpEncoder.FilenameExtension.Split(";").Replace("*","") > > -Teemu > > On Wednesday, January 16, 2008 11:04 AM > Teemu wrote: > > Re: ImageCodecInfo and array's references > Sorry, this is the right code: > > Dim FileExtension As String = _ > jgpEncoder.FilenameExtension.Split(";")(0).Replace("*","") > > -Teemu > > On Wednesday, January 16, 2008 11:25 AM > Teemu wrote: > > 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 > > On Thursday, January 17, 2008 5:30 AM > kimiraikkonen wrote: > > Re: ImageCodecInfo and array's references > On Jan 16, 1:54 pm, "Teemu" <tsir***@hotmail.com> wrote: > 10***@reader1.news.saunalahti.fi... > > > 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 > > On Thursday, January 17, 2008 5:30 AM > kimiraikkonen wrote: > > Re: ImageCodecInfo and array's references > On Jan 16, 4:24 pm, "Teemu" <tsir***@hotmail.com> wrote: > 1***@reader1.news.saunalahti.fi... > > > . > > 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. > > On Thursday, January 17, 2008 5:30 AM > kimiraikkonen wrote: > > Re: ImageCodecInfo and array's references > e77f-7dd8-409f-b214-8a968da97***@k39g2000hsf.googlegroups.com... > > 'Replace' is not a member of 'System.Array error happened. > > On Thursday, January 17, 2008 5:30 AM > kimiraikkonen wrote: > > Re: ImageCodecInfo and array's references > On Jan 16, 6:04 pm, "Teemu" <tsir***@hotmail.com> wrote: > 3***@reader1.news.saunalahti.fi... > > > 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/tutorials/aspnet/fc9a5bf6-f5bb-4443-a92a-c9a46fd3aeb2/wpf-gridview-sample-to-in.aspx
How Does ComboBox Determine What To Display?
vb.net 2008 display and print directory/subdirectories Foreign Currency Exchange Rates Web service Get email with Visual Basic 2008 Draw an arrow on a line How to read a Stream into an XElement how to use a common class in different projects Importing data from web site search for a string or part of a string in another string algoritm special permutation |
|||||||||||||||||||||||