Image.PixelFormat プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Image.PixelFormat プロパティの意味・解説 

Image.PixelFormat プロパティ

この Imageピクセル形式取得します

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public ReadOnly Property
 PixelFormat As PixelFormat
Dim instance As Image
Dim value As PixelFormat

value = instance.PixelFormat
public PixelFormat PixelFormat { get; }
public:
property PixelFormat PixelFormat {
    PixelFormat get ();
}
/** @property */
public PixelFormat get_PixelFormat ()
public function get PixelFormat
 () : PixelFormat

プロパティ
この Imageピクセル形式を表す PixelFormat。

使用例使用例

GetPixel および SetPixel メソッド使用してイメージの色を変更する方法次のコード例示しますまた、この例では PixelFormat プロパティ使用してます。

この例は、Label1 という名前の LabelPictureBox1 という名前の PictureBox、および Button1 という名前の Button含んだ Windows フォームでの使用意図してデザインされています。コードフォーム貼り付けButton1_Click メソッドボタンClick イベント関連付けます。

Dim image1 As Bitmap

Private Sub Button1_Click(ByVal
 sender As System.Object, _
    ByVal e As System.EventArgs) Handles
 Button1.Click

    Try
        ' Retrieve the image.
        image1 = New Bitmap( _
            "C:\Documents and Settings\All Users\Documents\My
 Music\music.bmp", _
            True)

        Dim x, y As Integer

        ' Loop through the images pixels to reset color.
        For x = 0 To image1.Width - 1
            For y = 0 To image1.Height - 1
                Dim pixelColor As Color = image1.GetPixel(x,
 y)
                Dim newColor As Color = _
                    Color.FromArgb(pixelColor.R, 0, 0)
                image1.SetPixel(x, y, newColor)
            Next
        Next

        ' Set the PictureBox to display the image.
        PictureBox1.Image = image1

        ' Display the pixel format in Label1.
        Label1.Text = "Pixel format: " + image1.PixelFormat.ToString()

    Catch ex As ArgumentException
        MessageBox.Show("There was an error." _
            & "Check the path to the image file.")
    End Try
End Sub
Bitmap image1;

private void Button1_Click(System.Object sender,
 System.EventArgs e)
{

    try
    {
        // Retrieve the image.
        image1 = new Bitmap(@"C:\Documents and Settings\All
 Users\" 
            + @"Documents\My Music\music.bmp", true);

        int x, y;

        // Loop through the images pixels to reset color.
        for(x=0; x<image1.Width; x++)
        {
            for(y=0; y<image1.Height; y++)
            {
                Color pixelColor = image1.GetPixel(x, y);
                Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
                image1.SetPixel(x, y, newColor);
            }
        }

        // Set the PictureBox to display the image.
        PictureBox1.Image = image1;

        // Display the pixel format in Label1.
        Label1.Text = "Pixel format: "+image1.PixelFormat.ToString();

    }
    catch(ArgumentException)
    {
        MessageBox.Show("There was an error." +
            "Check the path to the image file.");
    }
}
private:
   Bitmap^ image1;
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      try
      {
         
         // Retrieve the image.
         image1 = gcnew Bitmap( "C:\\Documents and Settings\\All Users\\"
         "Documents\\My Music\\music.bmp",true );
         int x;
         int y;
         
         // Loop through the images pixels to reset color.
         for ( x = 0; x < image1->Width; x++ )
         {
            for ( y = 0; y < image1->Height; y++ )
            {
               Color pixelColor = image1->GetPixel( x, y );
               Color newColor = Color::FromArgb( pixelColor.R, 0, 0 );
               image1->SetPixel( x, y, newColor );

            }

         }
         
         // Set the PictureBox to display the image.
         PictureBox1->Image = image1;
         
         // Display the pixel format in Label1.
         Label1->Text = String::Format( "Pixel format: {0}", image1->PixelFormat
 );
      }
      catch ( ArgumentException^ ) 
      {
         MessageBox::Show( "There was an error."
         "Check the path to the image file." );
      }

   }
private Bitmap image1;

private void button1_Click(Object sender, System.EventArgs
 e)
{
    try {
        // Retrieve the image.
        image1 = new Bitmap("C:\\Documents and Settings\\All
 Users\\"  
            + "Documents\\My Music\\music.bmp", true);

        int x, y;

        // Loop through the images pixels to reset color.
        for (x = 0; x < image1.get_Width(); x++) {
            for (y = 0; y < image1.get_Height(); y++) {
                Color pixelColor = image1.GetPixel(x, y);
                Color newColor = Color.FromArgb(pixelColor.get_R(), 0, 0);

                image1.SetPixel(x, y, newColor);
            }
        }

        // Set the PictureBox to display the image.
        pictureBox1.set_Image(image1);

        // Display the pixel format in label1.
        label1.set_Text("Pixel format: " 
            + image1.get_PixelFormat().ToString());
    }
    catch (ArgumentException exp) {
        MessageBox.Show(("There was an error."  
            + "Check the path to the image file."));
    }
} //button1_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からImage.PixelFormat プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からImage.PixelFormat プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からImage.PixelFormat プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Image.PixelFormat プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Image.PixelFormat プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS