 |
|
 |
This article disappointed me, for it give a very beautiful name but can do nothing at all.
|
| Sign In·View Thread·PermaLink | 2.25/5 (3 votes) |
|
|
|
 |
|
 |
Hi,
i haven't experience to diplay images. Please could't you tell me, how must i use the code? How can i load a tif-file? And how can i access the image with these code?
Many Thanks
Cola
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hello out there,
I am experimenting with TIFF images (from fax). I used Tiffmanager (in C# 2008)) to read my sample file. At the following line:
image=Image.FromFile(_ImageFileName);
I get the following exception:
System.OutOfMemoryException wurde nicht behandelt. Message="Nicht genügend Arbeitsspeicher." Source="System.Drawing" ...
Reading the same file with IrfanView works fine. This file saved (form IrfanView) without Compression can be read with Tiffmanager. In my application I woould like to read the files without having to call IrfanView for conversion.
Any ideas what I can do to read the file?
Thaks a lot.
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
 |
I think I'm hitting the same problem. The problem appears to be an unsupported/proprietary TIFF format.
modified on Thursday, February 5, 2009 4:39 PM
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
 |
I am reading a large tiff file and it fails on following line;
System.Drawing.Image image = System.Drawing.Image.FromFile(fileName);
It throws Out of Memory Exception.
Smalls files are okay, but for large files it throws this exception.
Anyone???? Very desparate for the solution.
Thanks, Ahmar
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there,
It is always good practice to use the Image.FromStream() to load the image files(even better for large images). Here is a sample -
using ( FileStream fs = new FileStream( "sample.tif", FileMode.Open ) ) using (Image img = Image.FromStream(fs, true, false)) { Graphics g = this.CreateGraphics(); g.DrawImage(img, 0, 0); }
Hope this solves ur problem 
------------------ Regards, Chandra Kant
modified on Wednesday, May 27, 2009 3:29 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
When I tried
pictureBox1.Image = Image.FromFile("aGeoTiffFile.tif");
I got an error: System.Exception: A Graphics object cannot be created from an image that has an indexed pixel format.
Can I load geoTiff file and access its meta info with C#?
Frank
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hmm...if I recall correctly, GeoTIFF images are TIFF 6.0 compliant. Also, I know for a fact that System.Drawing.Image can handle indexed pixel formats.
Have you tried reading the IFD(s) yourself?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I use JoinTiffImages function to merge tif. but can't merge MultiFrame tif. ex:A.tif merge B.tif,A.tif have Page2,B.tif also too. user JoinTiffImages function merge A and B to New tif is C.tif. but C.tif only A.tif Page1 and B.tif Page1,A Page2 and B Page2 not join. have anybody can tell my why? Please ! thanks
Jackie Lin
|
| Sign In·View Thread·PermaLink | 1.83/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
The issue with the Join methods is that they are only saving the active frame of each image (page 1 by default)
To resolve this issue, each image must have its frames looped through and saved to the stream using the following methods:
public static int GetPageCount(ref Image img) { if (img != null) { Guid objGuid = img.FrameDimensionsList(0); FrameDimension objDimension = new FrameDimension(objGuid); return img.GetFrameCount(objDimension); } else { //If the image is nothing, return a count of 0 return 0; } }
public static void SelectFrame(ref Image img, int index) { if (img != null) { Guid objGuid = img.FrameDimensionsList(0); FrameDimension objDimension = new FrameDimension(objGuid); if (index < img.GetFrameCount(objDimension) && index >= 0) { img.SelectActiveFrame(objDimension, index); } } }
In place of the current .Save lines of code, use the above methods like so:
... Bitmap bm=(Bitmap)Image.FromFile(strImageFile); for (int j = 0; j <= GetPageCount(bm) - 1; j++) { SelectFrame(bm, j); pages.SaveAdd(bm, ep); } ...
Be sure to also do this for the "frame==0" case to ensure the first image is saved fully to the result image - but use SaveAdd on pages 2 - x!
There is a more elegant solution to this, but this will get you by for now.
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
 |
The GetFileNameStartString receive a parameter, but not use it:
private string GetFileNameStartString(string strFullName) { int posDot=_ImageFileName.LastIndexOf("."); int posSlash=_ImageFileName.LastIndexOf(@"\"); return _ImageFileName.Substring(posSlash+1,posDot-posSlash-1); } It should be change for private string GetFileNameStartString() { int posDot = _ImageFileName.LastIndexOf("."); int posSlash = _ImageFileName.LastIndexOf(@"\"); return _ImageFileName.Substring(posSlash + 1, posDot - posSlash -1 ); }
Or
private string GetFileNameStartString(string strFullName) { int posDot = strFullName.LastIndexOf("."); int posSlash = strFullName.LastIndexOf(@"\"); return strFullName.Substring(posSlash + 1, posDot - posSlash - 1); }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
The System.Drawing.Image class has a property called EncoderParameters. Try to iterate through them to find the one called Encoder.Compression and then try to get its value.
|
| Sign In·View Thread·PermaLink | 2.44/5 (5 votes) |
|
|
|
 |
|
 |
In case someone needs this, I was unable to find a way to get the compression using GDI+ but you can do it by reading the TIFF file directly. Some resources:
TIFF Specification: http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf
A nice summary of all the possible values of the compression tag: (note that not all are supported by the .net framework) http://www.awaresystems.be/imaging/tiff/tifftags/compression.html
It's a bit of work 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there,
No work at all.
Here is a sample:
Enum Compression None RLE PackBits CCITT3 CCITT4 LZW End Enum
Private Function GetTIFFCompression(ByVal bmp As Bitmap) As Compression Dim proplist As Array = bmp.PropertyIdList Dim ID As Integer = proplist.IndexOf(proplist, 259) Dim prop() As System.Drawing.Imaging.PropertyItem prop = bmp.PropertyItems Dim rCompression As Compression rCompression = prop(ID).Value(0) Return rCompression End Function
Regards
|
| Sign In·View Thread·PermaLink | 2.33/5 (3 votes) |
|
|
|
 |
|
 |
Thanks for the tip - I had to write an IFD reader at work to get this info 
(I have to admit though, I enjoyed writing the reader!)
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Don't forget that TIFF acts container - so techically any frame (read as page) can contain any type of image - or even binary data that can not be understood by anyone else except your application. The most common compressions that TIFF files use are: Packbits (MAC RLE), JPEG (Progessive/sequential, WANG), ZIP, LZW for colors and JBIG (Enhanced JBIG), ITU G3/4 (CCIT3/CCIT4, Modified G3) for binary only (1bit). Binary files are usually used for faxed B/W documents (RFC2301 for more info); but color TIFF containters are more application definied and are not standardized to date.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for the article and the Code. It helpt out a lot in the merger and splitting of Tiff files. There is however one little issue regarding the implemented Dispose() function.
Here is my implementation of the Dispose function:
public void Dispose() { if ( image != null ) // Checks whether the image object was assigned before calling the Dispose. image.Dispose(); System.GC.SuppressFinalize(this); }
Regards, Arjo.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
I receive a general GDI error when I try to split a multipage .tif:
private void Form1_Load(object sender, System.EventArgs e) { folderBrowserDialog1.SelectedPath = "c:";
}
private void button2_Click(object sender, System.EventArgs e) { folderBrowserDialog1.ShowDialog(); textBox1.Text = folderBrowserDialog1.SelectedPath; }
private void button1_Click(object sender, System.EventArgs e) { openFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.FilterIndex = 2 ; openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK) { TiffManager Splitter = new TiffManager(openFileDialog1.FileName); ArrayList splitedFileNames=new ArrayList(); splitedFileNames = Splitter.SplitTiffImage(textBox1.Text, System.Drawing.Imaging.EncoderValue.CompressionNone); }
}
|
| Sign In·View Thread·PermaLink | 1.67/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
I guess that you forgot to set the TempWorkingDir property, it will in good shape after setting that. Sorry for I do not monitor for my own post at the regular basis.
|
| Sign In·View Thread·PermaLink | 1.75/5 (3 votes) |
|
|
|
 |
|
 |
Could use default system temp dir, if none has been set
public string TempWorkingDir { get { if (_TempWorkingDir == string.Empty) _TempWorkingDir = System.IO.Path.GetTempPath(); return _TempWorkingDir; } set{ _TempWorkingDir=value; } }
|
| Sign In·View Thread·PermaLink | 1.80/5 (5 votes) |
|
|
|
 |