2011-07-21 11 views
-1

OIを実行する前に、Microsoft Office Document Imaging(MODI)を使用していて、TIF ファイルをロードしようとしていますが、グレースケールに変換しようとしています。MODIを使用して画像をグレースケールに変更する

どうすればよいか分かりません。

私は私のコードでこれを持っている:

プライベートMODI.Document _MODIDocument = NULL;

_MODIDocument = new MODI.Document();

_MODIDocument.Create(filename); axMiDocView1.Document = _MODIDocument;

文書の画像部分をグレースケールに変換する方法を教えてもらえますか?

おかげ

+0

変更・テクノロジー組織写真を削除します。私たちはそのルートに行き、Officeでバージョンの問題に遭遇し、ネットワークドライブ上の破損したファイルを見つけ、Office 2010で中止しました。 – TrueWill

答えて

0
public static Bitmap Grayscale(Bitmap bitmap) 
{ 
    //Declare myBitmap as a new Bitmap with the same Width & Height 
    Bitmap myBitmap = new Bitmap(bitmap.Width, bitmap.Height); 

    for (int i = 0; i < bitmap.Width; i++) 
    { 
     for (int x = 0; x < bitmap.Height; x++) 
     { 
      //Get the Pixel 
      Color BitmapColor = bitmap.GetPixel(i, x); 
      //I want to come back here at some point and understand, then change, the constants 
      //Declare grayScale as the Grayscale Pixel 
      int grayScale = (int)((BitmapColor.R * 0.3) + (BitmapColor.G * 0.59) + (BitmapColor.B * 0.11)); 

      //Declare myColor as a Grayscale Color 
      Color myColor = Color.FromArgb(grayScale, grayScale, grayScale); 

      //Set the Grayscale Pixel 
      myBitmap.SetPixel(i, x, myColor); 
     } 
    } 
    return myBitmap; 
} 

Bitmap oldBitmap = new Bitmap(Server.MapPath("~/Db/Plates/" + dosyaadi), false); 
Bitmap newBitmap = Grayscale(new Bitmap(oldBitmap)); 
string name = "grayscale"; 
newBitmap.Save(Server.MapPath("~/Db/Plates/") + name + ".jpg", ImageFormat.Jpeg); 

下のClickイベントが、その後..

関連する問題