 |
|
 |
How can i combine Two Multipage tiff in to a single multipage Tiff
|
|
|
|
 |
|
 |
Have a look at this article .
I slightly modified the code from above with this one, have fun ! :
private void btnLoadImage_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
string filename=op.FileName.ToString();
loadMultipageTiff(filename);
}
}
private void loadMultipageTiff(string filename)
{
Bitmap bitmap = (Bitmap)Image.FromFile(filename);
int count = bitmap.GetFrameCount(FrameDimension.Page);
for (int idx = 0; idx < count; idx++)
{
bitmap.SelectActiveFrame(FrameDimension.Page, idx);
MemoryStream byteStream = new MemoryStream();
bitmap.Save(byteStream, ImageFormat.Tiff);
createPanel(byteStream);
}
}
int firstpanel = 0;
private void createPanel(MemoryStream byteStream)
{
Image loadImage = Image.FromStream(byteStream);
Panel p = new Panel();
|
|
|
|
 |
|
 |
perfect for my needs. Very simple and understandable code.
|
|
|
|
 |
|
 |
I am attempting to discover the formatted image size before it is written to the disk. The reason behind this is to limit the file size of the combined .tiff file.
Does anyone have an idea on how to do this? My initial thoughts were to create a MemoryStream and continually write the compressed images to this.
|
|
|
|
 |
|
 |
Hi
Please Help Me ...
Which EncoderValue to be used for JOINTIFFIMAGE and SPLLITTIFFIMAGE ??????
|
|
|
|
 |
|
 |
It works like a charm... thank you.
|
|
|
|
 |
|
 |
Thanks this is nice code which i am using for the tiff download
I want to write the out directly to response.write. So that it can be directly downloaded on user system via browser. Can you please tell me how to that?
|
|
|
|
 |
|
 |
This article disappointed me, for it give a very beautiful name but can do nothing at all.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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?
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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);
}
|
|
|
|
 |
|
 |
Hi,
How could i find out the compression type of a tif file?
|
|
|
|
 |
|
 |
hi there, did you find out how to find the compression type of a tiff file?
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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!)
|
|
|
|
 |