index > Visual C# General > Splitting Tiff Files...HELP!!!

Splitting Tiff Files...HELP!!!

I surely hope someone here can help me out, because I've looked all over the internet and have found nothing that helps. I've found some code that I thought would solve my problem, but none of it compiles!

My background - business programming with VB, from VB3 through VB.Net under .Net 2005. No graphics programming experience whatsoever.

My problem - write a C# routine (in .Net 2005) using GDI+ to take a tiff file containing multiple fax documents and split the file into multiple tiffs.

This is as far as I've been able to get:

static String[] SplitFile(String file_name)

{

System.Drawing.Image imageFile;

// File name hard-coded for testing...waiting to have file provided on server
imageFile = System.Drawing.
Image.FromFile("test.tif");

System.Drawing.Imaging.FrameDimension frameDimensions = new System.Drawing.Imaging.FrameDimension(imageFile.FrameDimensionsList[0]);

int NumberOfFrames = imageFile.GetFrameCount(frameDimensions);

int intFrame = 0;

while (intFrame < NumberOfFrames)

{

imageFile.SelectActiveFrame(frameDimensions, intFrame);

intFrame++;

}

imageFile.Dispose();

// Code below added so that module will compile. The assignment indicated the procedure should
//return a string array (I assume of file names for a later procedure to save the info to a db)

string
[] s;

s = new string[5];

s[0] = " ";

return s;

}




Mike
MikeTheTiger

You did not mention what error you get on compile time!

Anyhow Try this if it compiles:

return new string[1];

Best Regards,




RizwanSharp;
RizwanSharp

I guess I didn't make myself clear. There's no error, I just can't figure out how to write the code to split the file. I have the code to select the active frame, but don't know how to then save each frame to another file. Where I've gotten compile errors is in some code that I've found on the internet that doesn't compile and I didn't really understand the code well enough to even make an attempt to fix it; none of that code is included in my post. Again, I'm not a graphics programmer and am very much a novice at C#.

Thanks.




Mike
MikeTheTiger

Ahh! OK, I wish you get it done within 24 hours, If you dont get a solution then I'll try to check this code with a Tiff file and telll you the results I'm succeffull to accomlish this.

I wish you all the best!

Best Regards,




RizwanSharp;
RizwanSharp
Try this code, it stores the frames in files named 0.tif, 1.tif, etc in the same folder as your executable:

static String[] SplitFile(String file_name) {
System.Drawing.Image imageFile;
imageFile = System.Drawing.Image.FromFile(file_name);
System.Drawing.Imaging.FrameDimension frameDimensions = new System.Drawing.Imaging.FrameDimension(imageFile.FrameDimensionsList[0]);
int NumberOfFrames = imageFile.GetFrameCount(frameDimensions);
string[] paths = new string[NumberOfFrames];
for (int intFrame = 0; intFrame < NumberOfFrames; ++intFrame) {
imageFile.SelectActiveFrame(frameDimensions, intFrame);
Bitmap bmp = new Bitmap(imageFile);
paths[intFrame] = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\" + intFrame.ToString() + ".tif";
bmp.Save(paths[intFrame], System.Drawing.Imaging.ImageFormat.Tiff);
bmp.Dispose();
}
imageFile.Dispose();
return paths;
}

nobugz
Great!! It works!  This was driving me crazy.  Thanks!!!!


Mike
MikeTheTiger
reply 6

You can use google to search for other answers

 

More Articles

• CreateStroke with TabletPC SDK
• Component class, list of values to an attribute.
• MultiThreading
• Load Icon from file
• Capture Webcam
• Crystal Reports
• Compare Generics Dictionary
• sql autoincrement
• Label Justify text
• I need help...
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• How can I add a class in Active Director
• How to test for values in a DataRow
• Setting the position of a MessageBox
• UML Tools for .NET (especially for C#)
• Error handling
• exception as "security exception wa
• Compiler error ,why
• Session or viewstate, default value
• Application not responding
• Biztalk 2004 trial download
• [C# 2.0 b2 framework] can download c# co
• Please help me ! Urgent
• Intranet and Windows Media Server
• Profiler&MimberShip&webPartZone
• USING VIS c++ V 6 WITH c# OR c++.NET

Hot Articles

• Convert VC 6.0 to C#
• Crystal Reports Report Document
• how long a string can be??
• C# Hashtable Issue
• copy data from an pointer
• SerialPort - .GetPortNames method is mis
• Is there a sample code which can print I
• MSDN Library for VS.NET 2003 download
• best way to evaluate what type of contro
• DllImport and thread stack debugging
• IntPtr Marshal.AllocHGlobal(int) - Passi
• How can I identfy a clients email server
• overriding ToString () method for enumer
• receiving string parameters from registry
• How do I underline the accesskey in the

Recommend Articles

• Windows program startup
• where to find MSCOMM32.OCX?
• Windows Service .NET 2.0 MissingManifest
• Word spell checker ActiveX with C# of MS
• What is the best way to view a list of o
• Need help on drawing rectangle on htmldo
• Getting the panel's text of a scrollbar
• Unable to cast object of type 'System.Wi
• .NET Framework and compatibility
• Export to PDF
• converting image in a clipboard to memor
• ReportGeneration Application
• diference between search and Index in do
• My program code called the Windows API f
• Lock "controlBox" for userinput