 |
|
|
Hi I appreciate your effort for showing the image conversion capability on .Net. I would request if you have any Win32 code for these conversions which you can share.
I went to http://www.smalleranimals.com[^] site, one of the member has participated in the discussion. But it turns out they looking for money. And since i am building using all free tools including Visual studio express edition i would like not to overstep in costing.
Looking forward to positive response.
Regards Kavitesh.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The program whihc you have posted is good but gives error on overwriting the same opened file and same opened format.I understand that your program is more on changing the formats but i accidently found this one.Any suggestions please.
P S Walia
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hi, I would like to do this program in compact framework (ppc2003); How can i achieve this? because Compact doesn't have imageformat in system.drawing.image namespace.
Thank you. bye.
mak
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
The author is just showing you how to link in to code written for GDI+, he's not reading or writing anything. To get at other formats is a whole lot more work. There are 3rd party libraries, some are free and open source and may support some of these formats.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, I noticed that you have references on System.WinForms but really it will generate error from Beta2 since it is in System.Windows.Forms.
Just my 2 cents
binarg
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Here is my 2 cents fixed.
BTW, you should remove the conflicted reference (the one with '!') under Project Manager->Project ImageConverter->Reference, and add System.Windows.Forms.
The modified Form1.cs attached below the bottom of my signature. I fixed the code under VS.NET Arch. Ed.
-M.H.
// A C# Image Converter By George Anescu // http://www.codeproject.com/cs/media/imagconvert.asp#xx68636xx // // Modified by M.H. // // Form1.cs // compile with: /doc:Form1.xml using System; using System.Drawing; using System.Drawing.Imaging; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;
namespace ImageConverter { /// /// Form1 is the main platform for demostrating the graphics file transformation functions. /// public class Form1 : System.Windows.Forms.Form { /// /// The Container generated by C# wizard. /// /// private System.ComponentModel.Container components; /// /// The ComboBox provides the user to choose the filename extension for 'Save As' Button. /// /// private System.Windows.Forms.ComboBox m_cmbSaveAs; /// /// The ComboBox provides the user to choose the filename extension for 'Open' Button. /// /// private System.Windows.Forms.ComboBox m_cmbOpen; /// /// The PictureBox where the loaded picture previews. /// /// private System.Windows.Forms.PictureBox m_pictureBox; /// /// The 'Save As' Button. /// /// private System.Windows.Forms.Button m_btnSaveAs; /// /// The 'Open' Button. /// /// private System.Windows.Forms.Button m_btnOpen; /// /// The reference that holds the opened picture. /// /// private Bitmap m_bitmap; /// /// The width of PictureBox that determines whether the picture would be adjusted to the PictureBox size. /// /// private int m_width0; /// /// The height of PictureBox that determines whether the picture would be adjusted to the PictureBox size. /// /// private int m_height0;
/// /// The main windows which the application launches. /// public Form1() { InitializeComponent(); m_bitmap = null; m_width0 = m_pictureBox.Size.Width; m_height0 = m_pictureBox.Size.Height; }
/// /// Clean up any resources being used. /// protected override void Dispose(bool disposing) { try { if(disposing) { // Release the managed resources you added in // this derived class here. m_cmbSaveAs.Dispose(); m_cmbOpen.Dispose(); m_pictureBox.Dispose(); m_btnSaveAs.Dispose(); m_btnOpen.Dispose(); components.Dispose(); } } finally { // Call Dispose on your base class. base.Dispose(disposing); } }
/// /// Initialize the components/resources insides the windows. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container (); this.m_pictureBox = new System.Windows.Forms.PictureBox (); this.m_btnSaveAs = new System.Windows.Forms.Button (); this.m_cmbSaveAs = new System.Windows.Forms.ComboBox (); this.m_btnOpen = new System.Windows.Forms.Button (); this.m_cmbOpen = new System.Windows.Forms.ComboBox (); //@this.TrayHeight = 0; //@this.TrayLargeIcon = false; //@this.TrayAutoArrange = true; //@this.GridSize = new System.Drawing.Size (4, 4); m_pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; m_pictureBox.BackColor = System.Drawing.SystemColors.ControlDark; m_pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; m_pictureBox.Location = new System.Drawing.Point (116, 20); m_pictureBox.Size = new System.Drawing.Size (300, 300); m_pictureBox.TabIndex = 2; m_pictureBox.TabStop = false; m_btnSaveAs.Location = new System.Drawing.Point (20, 276); m_btnSaveAs.Size = new System.Drawing.Size (68, 28); m_btnSaveAs.TabIndex = 1; m_btnSaveAs.Enabled = false; m_btnSaveAs.Text = "SaveAs..."; m_btnSaveAs.Click += new System.EventHandler (this.btnSaveAs_Click); m_cmbSaveAs.Text = "*.bmp"; m_cmbSaveAs.Location = new System.Drawing.Point (20, 240); m_cmbSaveAs.Size = new System.Drawing.Size (76, 21); m_cmbSaveAs.TabIndex = 4; m_cmbSaveAs.Items.Add("*.bmp"); m_cmbSaveAs.Items.Add("*.jpg"); m_cmbSaveAs.Items.Add("*.gif"); m_cmbSaveAs.Items.Add("*.tif"); m_btnOpen.Location = new System.Drawing.Point (20, 76); m_btnOpen.Size = new System.Drawing.Size (68, 28); m_btnOpen.TabIndex = 0; m_btnOpen.Text = "Open..."; m_btnOpen.Click += new System.EventHandler (this.btnOpen_Click); m_cmbOpen.Text = "*.bmp"; m_cmbOpen.Location = new System.Drawing.Point (20, 40); m_cmbOpen.Size = new System.Drawing.Size (76, 21); m_cmbOpen.TabIndex = 3; m_cmbOpen.Items.Add("*.bmp"); m_cmbOpen.Items.Add("*.jpg"); m_cmbOpen.Items.Add("*.gif"); m_cmbOpen.Items.Add("*.tif"); this.Text = "Image Converter"; this.MaximizeBox = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.AutoScaleBaseSize = new System.Drawing.Size (5, 13); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.ClientSize = new System.Drawing.Size (434, 339); this.Controls.Add (this.m_cmbSaveAs); this.Controls.Add (this.m_cmbOpen); this.Controls.Add (this.m_pictureBox); this.Controls.Add (this.m_btnSaveAs); this.Controls.Add (this.m_btnOpen); } /// /// The function triggered by 'Save As' Button event. The SaveFileDialog will launch after 'Save As' /// button being clicked, assign the extension according to m_cmbSaveAs instance holds, and then save /// to the new formatted file. /// /// /// protected void btnSaveAs_Click (object sender, System.EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save Image As"; sfd.OverwritePrompt = true; sfd.CheckPathExists = true; sfd.Filter = m_cmbSaveAs.Text + "|" + m_cmbSaveAs.Text; sfd.ShowHelp = true; if(sfd.ShowDialog() == DialogResult.OK) { string strFileName = sfd.FileName; switch(m_cmbSaveAs.Text) { case "*.bmp": m_bitmap.Save(strFileName, ImageFormat.Bmp); break;
case "*.jpg": m_bitmap.Save(strFileName, ImageFormat.Jpeg); break;
case "*.gif": m_bitmap.Save(strFileName, ImageFormat.Gif); break;
case "*.tif": m_bitmap.Save(strFileName, ImageFormat.Tiff); break; } this.Text = "Image Converter: " + strFileName; } } /// /// The function triggered by 'Open' Button event. The OpenFileDialog will launch after 'Open' /// button being clicked to open graphics file(s) with the extension that m_cmbOpen instance /// holds. After the file open successfully, the preview box will show the thumbnail about /// what picture looks like; and enable the 'Save As' button. /// /// /// protected void btnOpen_Click (object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = m_cmbOpen.Text + "|" + m_cmbOpen.Text; string filter = ofd.Filter; ofd.InitialDirectory = System.Environment.CurrentDirectory; ofd.Title = "Open Image File"; ofd.ShowHelp = true; if(ofd.ShowDialog() == DialogResult.OK) { string strFileName = ofd.FileName; m_bitmap = new Bitmap(strFileName); if(m_bitmap.Width > m_bitmap.Height) { //Keep the width m_pictureBox.Width = m_width0; m_pictureBox.Height = (int)((double)m_bitmap.Height*m_width0/m_bitmap.Width); } else { //Keep the height m_pictureBox.Height = m_height0; m_pictureBox.Width = (int)((double)m_bitmap.Width*m_height0/m_bitmap.Height); } m_pictureBox.Image = m_bitmap; this.Text = "Image Converter: " + strFileName; m_btnSaveAs.Enabled = true; } }
/// /// The main entry point for the application. /// public static void Main(string[] args) { Application.Run(new Form1()); } } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The article will be updated to release version of VS.NET with your code. Thank you for your contribution!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
you can't legally use .NET to read or write GIFs.
http://www.microsoft.com/DEVONLY/Unisys.htm
http://www.unisys.com/unisys/lzw/
-c
------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
|
| Sign In·View Thread·PermaLink | 3.00/5 (1 vote) |
|
|
|
 |
|
|
I have never used and I don't intend to use. This article is just showing some .NET capabilities. If somebody is using the code is his responsability to check in advance the legality of his actions.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I thought you could use GIF if you didn't sell the product. Any money making projects that write the GIF format need to pay royaltees, but i thought freeware was immune to this. (I could be wrong)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
you cannot use GIF at all unless you pay royalties to Unisys.
there is no exception for freeware, shareware, trialware or any-other-ware. you must pay royalties on every copy you ditribute. Unisys will probably refuse to even license you if you aren't charging for the program. i've tried licensing free programs and they literally laughed at me. they didn't laugh when we licensed our non-free programs.
reading and writing are both covered.
non-LZW GIF writers and readers are possibly OK, but possibly not - nobody has been taken to court over them yet (that i know of).
go to www.unisys.com and do a search on "LZW".
-c
------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I was under the impression that the compression algorithm is what's patented, not the GIF format itself. For example, the October issue of Dr. Dobb's has an article on an alternative compression algorithm, which they explain sidesteps the Unisys royalty issue.
Please correct me if I'm incorrect here.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
There are numerous ways to write something that GIF can read, which the authors claim sidestep the patent, and Unisys claim does not. The safest way is not to use it. My Doodle sample ( which BTW does everything this article does and more ) and every program I write to use GDI+ to save and load images, do all they can to fail if a gif is read, and will not write them. Why Microsoft opened this can of worms for us, instead of allowing us to choose the formats we will read/write to is beyond me ( I know of no way to stop GDI+ from ever reading a GIF ).
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The GIF format is owned by CompuServe and is available for unlimited use to the public.
If your GIF is internally compressed with the LZW77, then you must pay royalties to Unisis. The GIF standard does support other compressions (such as RLE and zip-style compression), but none are as effective.
I am no lawyer, and it is more complicated than this, of course. So, do your homework and CYA if you plan to use GIFs, because I'm not giving advice here... just a heads-up. 
The best choice is not to use GIF at all (after all, GIF is pretty much useless without LZW). Stick with jpeg for "photo quality" images, and PNG as a replacement for the GIF. If you're looking for a replacement for animated gif, use Flash (Macromedia), SVG (Adobe), Liquid Motion (Microsoft - Not sure if this is still around) or AVI/MPEG (too big really, unless you need photo-quality and sound). Flash has the biggest market share for web animation.
-Mike Stevenson CoderX@liquidmirror.com Owner, Liquid Mirror Software (http://www.liquidmirror.com) Owner, USA vs Afghanistan (http://www.usavsafghanistan.com/) Owner, Shareware Junction (http://www.sharewarejunction.com) Owner, Internet Shopping Spree (http://www.internetshoppingspree.com/)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Mike Stevenson wrote: The GIF format is owned by CompuServe and is available for unlimited use to the public.
Wrong - Compuserve folded completely in the face of Unisys, and Unisys claim ownership of any GIF format, even though you're right that Unisys claim patent on the compression only.
Unisys are scum.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
You can use GIF in C# because Microsoft would have paid the fees for it when they built in the support for it. You do not have to pay for it unless you decode it and render it yourself.
fadi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |