• ベストアンサー

GetEncoderInfoの指定の仕方

myImageCodecInfo = GetEncoderInfo("image/jpeg"); というサンプルがあり GetEncoderInfoで取得しようとしますと クラスまたは関数がありませんと出てきますが 例にある using System; using System.Drawing; using System.Drawing.Imaging; は指定してあります 他に指定しなければいけないのでしょうか?

質問者が選んだベストアンサー

  • ベストアンサー
  • ittochan
  • ベストアンサー率64% (2667/4137)
回答No.1

>他に指定しなければいけないのでしょうか? そんなことないです。 GetEncoderInfoって自分で作成するのでは? >というサンプルがあり そのサンプルに Private Shared Function GetEncoderInfo(???????) みたいな関数が書かれていませんか?

easy_gontyan
質問者

お礼

ありました 下の方で気づきませんでした ありがとうございました

関連するQ&A

  • C#の保存フォーマット指定

    C♯のプログラムで 保存、読み込みにおいてbmp以外にjpgとgifを指定しないといけないのですが、 >saveFileDialog1.Filter =のあとの“イメージ(*.bmp)…には追加したのですが、 >そのあとの System.Drawing.Imaging.ImageFormat.Bmp: の部分を変えないといけないのですが、そこが分からなくて詰まっています! 誰か教えてください! お願いします

  • デスクトップイメージを高画質でファイル化したい

    (1) デスクトップのフルスクリーンイメージを「Print Screen」でクリップボードに取り込んで、 System.Drawing.Image として宣言した変数に My.Computer.Clipboard.GetImage() で格納し、 System.Drawing.Imaging.ImageFormat.Png System.Drawing.Imaging.ImageFormat.Jpeg System.Drawing.Imaging.ImageFormat.Bmp でファイル化しました。 (2) 同じデスクトップのフルスクリーンイメージを ペイント、ワード(解像度デフォルト)、GIMPに取り込んでファイル化したデータと比較したところ、 PNGファイル以外は程度の差はあるが、何れも(1)の方が画質が悪かったです。 質問ですが、 VBでデスクトップイメージを高画質でファイル化できないでしょうか?

  • C#で派生クラスから描画処理を行う

    C#を勉強しているのですが、GUIを作り初めて描画処理で分からない所があり、質問させて頂きます。 基本クラスの方で「Hello, world!」という文字列をDrawStringで表示させる事は出来たのですが、それを基本クラスを継承した派生クラスのメソッドで行うと何も表示されないんです。 以下が試したコードです。 //基本クラスSample1 using System; using System.Drawing; using System.Windows.Forms; public class Sample1 : Form {   protected Bitmap image; protected Graphics g; protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Sample2 s = new Sample2(); s.helloworld(); e.Graphics.DrawImage(image, 0, 0); } public Sample1() { SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); image = new Bitmap(600, 400); g = Graphics.FromImage(image); } static void Main() { Form form = new Sample1(); form.Text = "sample"; form.ClientSize = new Size(600, 400); form.BackColor = Color.FromArgb(0xff, 0xff, 0xff); Application.Run(form); } } //派生クラスSample2 using System; using System.Drawing; using System.Windows.Forms; public class Sample2 : Sample1 { Brush brush = new SolidBrush(Color.Black); public void helloworld() { g.DrawString("Hello, world!", this.Font, brush, 10, 10); } } なぜ表示されないのか分かる方いらしたら、ご教授願えないでしょうか。是非お願いします。

  • 色の変更

    また分からないことが出来ましたので、よろしくお願いいたします。 今、openFileDialogで画像を読取、その画像の黒色を白色に変更してpicutreBoxに表示するプログラムを作成しています。 [C#] Bitmap img = new Bitmap(openFileDialog.FileName); Graphics g = Graphics.FromImage(img); System.Drawing.Imaging.ColorMap[] cms = new System.Drawing.Imaging.ColorMap[] {new System.Drawing.Imaging.ColorMap(), new System.Drawing.Imaging.ColorMap()}; cms[0].OldColor = Color.Black; cms[0].NewColor = Color.White; System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes(); ia.SetRemapTable(cms); g.DrawImage(img, new Rectangle(img.Width + 10, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel,ia); g.Dispose(); PictureBox1.Image = img; という風に作成したのですが、色が変更されませんでした。 どこが違うのか分かられる方がいらっしゃいましたら、よろしくお願いいたします。

  • C# でパネルのマウスイベントが取得できない

    OpenNI(キネクトセンサー)のサンプルプログラムは、C#のパネルにbitmapを描画し続けるのですが、 描画中、そのパネルのマウスイベントが生じない(無視されている?)ようです。マウスの位置から 補助線を引いたりしたいのですが、描画中にマウスイベントが取得できる方法をご存知の方、お願いします。以下サンプルソースそのままです。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; using OpenNI; using System.Threading; using System.Drawing.Imaging; namespace SimpleViewer.net { private unsafe void ReaderThread() { DepthMetaData depthMD = new DepthMetaData(); while (this.shouldRun) { try { this.context.WaitOneUpdateAll(this.depth); } catch (Exception) { } this.depth.GetMetaData(depthMD); lock (this) { Rectangle rect = new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height); BitmapData data = this.bitmap.LockBits(rect, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); ushort* pDepth = (ushort*)this.depth.DepthMapPtr.ToPointer(); // set pixels for (int y = 0; y < depthMD.YRes; ++y) { byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride; for (int x = 0; x < depthMD.XRes; ++x, ++pDepth, pDest += 3) { byte pixel = (byte)this.histogram[*pDepth]; pDest[0] = 0; pDest[1] = pixel; pDest[2] = pixel; } } this.bitmap.UnlockBits(data); } this.Invalidate(); } } private readonly string SAMPLE_XML_FILE = @"../../../Data/SamplesConfig.xml"; private Context context; private ScriptNode scriptNode; private DepthGenerator depth; private Thread readerThread; private bool shouldRun; private Bitmap bitmap; private int[] histogram; } }

  • C# MakeTransparent関数について

    C#において元画像の1ピクセルを指示し,画像の透過処理を MakeTransparent関数を用いて実行しようとしたところ, 「'System.Drawing.Image' に 'MakeTransparent' の定義がありません。」 と表記されビルドすることができませんでした。 制作環境はVisual Studio.NET 2003,VisualC# 2005 Express Edition の2つを用いたのですがどちらも同じエラーでありました。 初期の定義である using System.Drawing にはMakeTransparent関数 を使用することが出来る定義は存在していないのでしょうか? 宜しければ回答をお願いします。

  • Using System.Drawing がうまく使えなくて困っていま

    Using System.Drawing がうまく使えなくて困っています. C# に取り組んでいる初心者です.先日も、この欄でご教示を戴きました.有難うございました. 再度恐縮ですが、お願いをいたします. 簡単な Y = f(X) のグラフを描かせたいと考えています. ところが、肝心な DrawLine の命令が使えません. この命令は、System.Drawing と言う NameSpace に属していると思います. ところが、using System.Drawing とすると、Drawing に朱色で下線が付きます. なぜ受けつけないのか、さっぱりわかりません. そこで、下記のように、プログラムの頭に、いろんな NameSpace を書いてみました using System; using System.Math; using System.Console; using System.IO; using System.Text; using System.Collections; using System.Drawing; using System.Windows.Forms; 結果は、最後の二つの、 Drawing と Windows に朱下線が付きます. エラーメッセージはつぎのとおりです. 「エラー1 型または名前空間名 'Drawing' は名前空間 'System' に存在しません。アセンブリ参照が不足しています」 いったい、どう言うことでしょう? お手数をかけて申し訳ありませんが、 どうぞ、よろしくご教示をお願いします. グラフに使用するX,Yの座標値の計算は、問題なく終わっています. テーマは、電子回路の回路網の解析です. すべて数値計算になりますので、ニュートン近似か、2分法で最適値を求めています 使用している環境は、次のとおりです. NEC ValueOne CPU Athlon 64x2 4200+ Memory 1GB OS XP SP3 Visual C# 2010 Express

  • VB.NETでのPictureBoxによる画像保存について

    またお世話になります。 VB.NETでプログラムでPictureBoxに絵を描かせているのですが、そこまでは表示させることができました。このできた画像をBitmapなりjpegなりに保存させて、ほかの画像ビューワ等でも見れる形にしたいのですがうまくいきません。 ちなみに今はこのように書いて、 Dim gra1 As Graphics = PictureBox1.CreateGraphics FileOpen(2, myfile2, OpenMode.Output) (絵を描かせるプログラム) PictureBox1.Image.Save(myfile2, System.Drawing.Imaging.ImageFormat.Bmp) FileClose(2) としてまわしたところ、 System.Runtime.InteropServices.ExternalException' のハンドルされていない例外が system.drawing.dll で発生しました。 追加情報 : GDI+ で一般的なエラーが発生しました。 といわれました。 どなたかご教授いただけたらお願いしますm(__)m

  • C#のGraphicsクラスについて(GDI+)

    以下のようにgraphicsクラスをつかった画像の描画をおこないました。 Graphics gr = Graphics.FromImage(mapObj); というふうにからのリソースからGraphicsオブジェクトをつくる方法です。 using System; using System.IO; using System.Windows.Forms; using System.Drawing; using System.Web; using System.Net; using System.Text; using System.Threading; using System.ComponentModel; public class MainClass{ public static void Main(string [] args){ NewForm formObj = new NewForm(); formObj.RenderMethod(); Application .Run(formObj); } } public class NewForm : Form{ public NewForm(){ this.Width = 500; this.Height = 500; } public void RenderMethod(){ Bitmap mapObj = new Bitmap(500,500); Graphics gr = Graphics.FromImage(mapObj); Image imageObj = Image.FromFile("C:\\test.jpg"); gr .DrawImage(imageObj, 0,0,150,150); this.BackgroundImage = mapObj; } } このほかに、フォームコントロールの thisl.CreateGraphics()という メソッドを使っても画像を描画できるとききました。 あるサンプルをみると public class NewForm : Form{ public NewForm(){ this.Width = 500; this.Height = 500; } public void RenderMethod(){ Graphics gr = this.CreateGraphics(); Image imageObj = Image.FromFile("C:\\test.jpg"); gr .DrawImage(imageObj, 0,0,150,150); } } とこのようにthis.CreateGraphics()をつかっていましたが 実際にはこれが描画されないのです。 Graphics gr = Graphics.FromImage(mapObj); というGraphicsクラスの静的メソッドを使う方法ではなく コントロールのCreateGraphicsメソッドをつかって描画するにはどうしたらよいのですか? 識者のかた、ご教授ください。

  • 動的に画像を作成し保存するには?

    Visual Basic 2012を使用しています。 下記プログラムを実行するとエラーが表示されてしまいます。 Dim img As New Bitmap(200, 100) Dim g As Graphics = Graphics.FromImage(img) g.FillRectangle(Brushes.Black, g.VisibleClipBounds) g.Dispose() PictureBox1.Image = img img.Save("E:\EPUB_test\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg) img.Dispose() 表示されるエラーは下記です。 型 'System.ArgumentException' のハンドルされていない例外が System.Drawing.dll で発生しました どこが間違っているのでしょうか? 正しく動作させるにはどこを修正すべきかをお教え下さい。