次の方法で共有


Graphics.DrawImageUnscaled メソッド (Image, Int32, Int32)

指定したイメージを座標ペアで指定された位置に元の物理サイズで描画します。

Overloads Public Sub DrawImageUnscaled( _
   ByVal image As Image, _   ByVal x As Integer, _   ByVal y As Integer _)
[C#]
public void DrawImageUnscaled(Imageimage,intx,inty);
[C++]
public: void DrawImageUnscaled(Image* image,intx,inty);
[JScript]
public function DrawImageUnscaled(
   image : Image,x : int,y : int);

パラメータ

  • image
    描画する Image オブジェクト。
  • x
    描画イメージの左上隅の x 座標。
  • y
    描画イメージの左上隅の y 座標。

戻り値

このメソッドは値を返しません。

解説

Image オブジェクトは、ピクセル幅の値および水平方向の解像度 (dpi) の値を格納します。イメージの物理的な幅 (インチ) は、ピクセル幅を水平解像度で割った値です。たとえば、ピクセル幅 216、水平解像度 72 dpi のイメージの物理的な幅は 3 インチです。ピクセルの高さと物理的な高さについても同様です。

DrawImageUnscaled メソッドは物理サイズを使用してイメージを描画するため、イメージは表示デバイスの解像度 (dpi) に関係なく、インチで示された正確なサイズで描画されます。たとえば、ピクセル幅が 216、水平解像度が 72 dpi のイメージがあるとします。解像度が 96 dpi のデバイスに DrawImageUnscaled を呼び出してイメージを描画すると、描画されるイメージのピクセル幅は (216/72)*96 = 288 になります。

DrawImageUnscaled(image, x, y) 呼び出しは、DrawImage(image, x, y) 呼び出しとまったく同じ意味を持ちます。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • この例が保存されているフォルダの JPEG ファイル SampImag.jpg からイメージを作成します。
  • イメージの左上隅を描画する点を作成します。
  • 物理サイズを使用してイメージ全体を描画します。
 
Public Sub DrawImageUnscaledInt(e As PaintEventArgs)
' Create image.
Dim newImage As Image = Image.FromFile("SampImag.jpg")
' Create coordinates for upper-left corner of image.
Dim x As Integer = 100
Dim y As Integer = 100
' Draw image to screen.
e.Graphics.DrawImageUnscaled(newImage, x, y)
End Sub
        
[C#] 
public void DrawImageUnscaledInt(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create coordinates for upper-left corner of image.
int x = 100;
int y = 100;
// Draw image to screen.
e.Graphics.DrawImageUnscaled(newImage, x, y);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.DrawImageUnscaled オーバーロードの一覧