473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

How to generate GIF image with these properties Non-Interlaced GIF (CompuServe) 89a 2

Hi All

I have one doc file i want to convert that .doc file to .GIF file with the following properties

Non-Interlaced GIF (CompuServe) 89a
2 colors (1-bit)
Horizontal Resolution 96 dpi
Vertical Resolution 96 dpi
Bit depth 8

below is the code that i have used. I am converting doc file to .tiff first and then tiff to .gif file. This code is working fine on windows 7 but not on XP. Also it setting Horizontal and Vertical Resolution to 200 dpi, although I am setting the resolution in code to 96 dpi.

Can anybody help me out...

Expand|Select|Wrap|Line Numbers
  1. string extractedText = string.Empty;
  2.             string getFileName;
  3.             string FinalImg;
  4.             string PrintImage;
  5.  
  6.             Microsoft.Office.Interop.Word._Application msdoc = new Microsoft.Office.Interop.Word.Application();
  7.  
  8.             getFileName = "D:\\test.doc";
  9.             PrintImage = "D:\\DocToImage.tif";
  10.             FinalImg = "D:\\DocToImage.gif";
  11.  
  12.  
  13.              object fileName = @getFileName;
  14.             object PrintToFile = true;
  15.             object OutputFileName = PrintImage;
  16.             object varMissing = Type.Missing;
  17.             object varFalseValue = false;
  18.             object varTrueValue = true;
  19.             object Fileformat = System.Drawing.Imaging.ImageFormat.Gif;
  20.             object Letter = true;
  21.  
  22.             msdoc.ActivePrinter = "Microsoft Office Document Image Writer";
  23.  
  24.             Microsoft.Office.Interop.Word._Document doc = msdoc.Documents.Open(ref fileName, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing);
  25.  
  26.             doc.PrintOut(ref varMissing, ref varFalseValue, ref varMissing, ref OutputFileName, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref PrintToFile, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing);
  27.  
  28.             doc.Close(ref varMissing, ref varMissing, ref varMissing);
  29.             msdoc.Quit(ref varMissing, ref varMissing, ref varMissing);
  30.  
  31.             System.Threading.Thread.Sleep(30000);
  32.              Bitmap bmp = new Bitmap(PrintImage);
  33.                   System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.SaveFlag;
  34.                   //System.Drawing.Imaging.Encoder enc2 = System.Drawing.Imaging.Encoder.ColorDepth;
  35.                   //EncoderParameter myEncoderParameter;
  36.                   System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
  37.                   System.Drawing.Imaging.ImageCodecInfo info = null;
  38.                   foreach (System.Drawing.Imaging.ImageCodecInfo ice in System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders())
  39.                       if (ice.MimeType == "image/tiff")
  40.                           info = ice;
  41.  
  42.                   System.Drawing.Imaging.EncoderParameters ep = new System.Drawing.Imaging.EncoderParameters(3);
  43.                   //myEncoderParameter =new EncoderParameter(enc2, 8L);
  44.                   ep.Param[0] = new System.Drawing.Imaging.EncoderParameter(enc, (long)System.Drawing.Imaging.EncoderValue.MultiFrame);
  45.                   ep.Param[1] = new System.Drawing.Imaging.EncoderParameter(enc, (long)System.Drawing.Imaging.ColorMode.Argb32Mode);
  46.                   ep.Param[2] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 4L);
  47.                   //ep.Param[2] = myEncoderParameter;
  48.                   bmp.SetResolution(96, 96);
  49.                   bmp.Save(FinalImg, info, ep);
  50.  
  51.                   int ImgFrameCount = bmp.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
  52.  
  53.                   for (int i = 0; i < ImgFrameCount; i++)
  54.                   {
  55.                       if (i == 0)
  56.                           continue;
  57.  
  58.                       bmp.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i);
  59.                       bmp.SetResolution(96, 96);
  60.  
  61.  
  62.                       ep.Param[0] = new System.Drawing.Imaging.EncoderParameter(enc, (long)System.Drawing.Imaging.EncoderValue.FrameDimensionPage);
  63.                       ep.Param[1] = new System.Drawing.Imaging.EncoderParameter(enc, (long)System.Drawing.Imaging.EncoderValue.VersionGif89);
  64.                       ep.Param[2] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8L);
  65.  
  66.                       //ep.Param[2] = myEncoderParameter;
  67.                       bmp.SaveAdd(ep);
  68.                   }               
  69.  
  70.                   bmp.Dispose();
  71.  
Aug 5 '11 #1
0 877

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Robert Peden | last post by:
Hi All, I have used javascript to chamge a button's image when the mouse moves over the button (graphic) without problems. But I have come upon a new challenge - buttons which overlay each...
4
by: Karthik Seetharaman | last post by:
I have to aspx pages default.aspx and imagegen.aspx default.aspx has an image webcontrol whose imageurl property is set to imagegen.aspx. imagegen.aspx generates a bitmap image and writes it to...
5
by: Popoxinhxan | last post by:
HI guy I am working on the web application that required to display the chart image on the page. The process is clicking the button and browser will popup another windows that displayed...
0
by: Chad A. Beckner | last post by:
Hey all, I know I've seen this code out there, just can't remember where. I want to generate an image of a webpage using ASP .NET. Kind of like Microsoft does with their search companion. ...
3
by: Paul Loveless | last post by:
Hi all, I would like to create a routine that retrieves specific properties from an image file (ex. a jpeg) without having to open the file. For example, in WinXP when you right-click a jpg file...
3
by: Rajiv Das | last post by:
C# 2.0 XP SP2 In My Code, I am using HttpWebRequest to visit a particular URL. I am required to generate a snapshot image (if this request were made through say IE) and save as jpeg. About .1...
0
by: ptkumar | last post by:
Hi All, I am using JfreeCharts. I have to generate an image(Pie Graph) in a jsp file. That jsp file image should be display into an .xls file. please help me on this. kumar
2
by: devi1985 | last post by:
How to get the width and height of an imagefile in java thankyou for ur reply.
0
by: Tem | last post by:
I need to draw a black circle using WPF and generate an image file. I used the following but it resulted in a blank file. I cannot figure out what is wrong with it. Thanks, Tem ...
9
by: saifulhaque | last post by:
I want to set colums, TemplateFied,HeaderTemplate,ItemTemplate with (LinkButton-Text,CommandName,Onclick etc) Here I am showing my code t_name table name it is varable,I want to set various table...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.