Encoder.ColorDepth フィールド
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Shared ReadOnly ColorDepth As Encoder
public: static initonly Encoder^ ColorDepth

BMP ファイルから Bitmap オブジェクトを作成する例を次に示します。このコードは、1 ピクセルあたり 24 ビットの色深度の TIFF ファイルとしてイメージを保存します。
Imports System Imports System.Drawing Imports System.Drawing.Imaging Imports Microsoft.VisualBasic Class Example_SetColorDepth Public Shared Sub Main() Dim myBitmap As Bitmap Dim myImageCodecInfo As ImageCodecInfo Dim myEncoder As Encoder Dim myEncoderParameter As EncoderParameter Dim myEncoderParameters As EncoderParameters ' Create a Bitmap object based on a BMP file. myBitmap = New Bitmap("C:\Documents and Settings\All Users\Documents\My Music\music.bmp") ' Get an ImageCodecInfo object that represents the TIFF codec. myImageCodecInfo = GetEncoderInfo("image/tiff") ' Create an Encoder object based on the GUID ' for the ColorDepth parameter category. myEncoder = Encoder.ColorDepth ' Create an EncoderParameters object. ' An EncoderParameters object has an array of EncoderParameter ' objects. In this case, there is only one ' EncoderParameter object in the array. myEncoderParameters = New EncoderParameters(1) ' Save the image with a color depth of 24 bits per pixel. myEncoderParameter = New EncoderParameter(myEncoder, CType(24L, Int32)) myEncoderParameters.Param(0) = myEncoderParameter myBitmap.Save("Shapes24bpp.tiff", myImageCodecInfo, myEncoderParameters) End Sub Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo Dim j As Integer Dim encoders() As ImageCodecInfo encoders = ImageCodecInfo.GetImageEncoders() j = 0 While j < encoders.Length If encoders(j).MimeType = mimeType Then Return encoders(j) End If j += 1 End While Return Nothing End Function End Class
using System; using System.Drawing; using System.Drawing.Imaging; class Example_SetColorDepth { public static void Main() { Bitmap myBitmap; ImageCodecInfo myImageCodecInfo; Encoder myEncoder; EncoderParameter myEncoderParameter; EncoderParameters myEncoderParameters; // Create a Bitmap object based on a BMP file. myBitmap = new Bitmap(@"C:\Documents and Settings\All Users\Documents\My Music\music.bmp"); // Get an ImageCodecInfo object that represents the TIFF codec. myImageCodecInfo = GetEncoderInfo("image/tiff"); // Create an Encoder object based on the GUID // for the ColorDepth parameter category. myEncoder = Encoder.ColorDepth; // Create an EncoderParameters object. // An EncoderParameters object has an array of EncoderParameter // objects. In this case, there is only one // EncoderParameter object in the array. myEncoderParameters = new EncoderParameters(1); // Save the image with a color depth of 24 bits per pixel. myEncoderParameter = new EncoderParameter(myEncoder, 24L); myEncoderParameters.Param[0] = myEncoderParameter; myBitmap.Save("Shapes24bpp.tiff", myImageCodecInfo, myEncoderParameters); } private static ImageCodecInfo GetEncoderInfo(String mimeType) { int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for(j = 0; j < encoders.Length; ++j) { if(encoders[j].MimeType == mimeType) return encoders[j]; } return null; } }
#using <System.Drawing.dll> using namespace System; using namespace System::Drawing; using namespace System::Drawing::Imaging; static ImageCodecInfo^ GetEncoderInfo( String^ mimeType ); int main() { Bitmap^ myBitmap; ImageCodecInfo^ myImageCodecInfo; Encoder^ myEncoder; EncoderParameter^ myEncoderParameter; EncoderParameters^ myEncoderParameters; // Create a Bitmap object based on a BMP file. myBitmap = gcnew Bitmap( "C:\\Documents and Settings\\All Users\\Documents\\My Music\\music.bmp" ); // Get an ImageCodecInfo object that represents the TIFF codec. myImageCodecInfo = GetEncoderInfo( "image/tiff" ); // Create an Encoder object based on the GUID // for the ColorDepth parameter category. myEncoder = Encoder::ColorDepth; // Create an EncoderParameters object. // An EncoderParameters object has an array of EncoderParameter // objects. In this case, there is only one // EncoderParameter object in the array. myEncoderParameters = gcnew EncoderParameters( 1 ); // Save the image with a color depth of 24 bits per pixel. myEncoderParameter = gcnew EncoderParameter( myEncoder,__int64(24) ); myEncoderParameters->Param[ 0 ] = myEncoderParameter; myBitmap->Save( "Shapes24bpp.tiff", myImageCodecInfo, myEncoderParameters ); } static ImageCodecInfo^ GetEncoderInfo( String^ mimeType ) { int j; array<ImageCodecInfo^>^encoders; encoders = ImageCodecInfo::GetImageEncoders(); for ( j = 0; j < encoders->Length; ++j ) { if ( encoders[ j ]->MimeType == mimeType ) return encoders[ j ]; } return nullptr; }
import System.* ; import System.Drawing.* ; import System.Drawing.Imaging.* ; class Example_SetColorDepth { public static void main(String[] args) { Bitmap myBitmap; ImageCodecInfo myImageCodecInfo; Encoder myEncoder; EncoderParameter myEncoderParameter; EncoderParameters myEncoderParameters; // Create a Bitmap object based on a BMP file. myBitmap = new Bitmap("C:\\Documents and Settings\\All Users" + "\\Documents\\My Music\\music.bmp"); // Get an ImageCodecInfo object that represents the TIFF codec. myImageCodecInfo = GetEncoderInfo("image/tiff"); // Create an Encoder object based on the GUID // for the ColorDepth parameter category. myEncoder = Encoder.ColorDepth; // Create an EncoderParameters object. // An EncoderParameters object has an array of EncoderParameter // objects. In this case, there is only one // EncoderParameter object in the array. myEncoderParameters = new EncoderParameters(1); // Save the image with a color depth of 24 bits per pixel. myEncoderParameter = new EncoderParameter(myEncoder, 24L); myEncoderParameters.get_Param().set_Item( 0 , myEncoderParameter ); myBitmap.Save("Shapes24bpp.tiff", myImageCodecInfo, myEncoderParameters); } //main private static ImageCodecInfo GetEncoderInfo(String mimeType) { int j; ImageCodecInfo encoders[]; encoders = ImageCodecInfo.GetImageEncoders(); for (j = 0; j < encoders.length; j++) { if ( encoders[j].get_MimeType().Equals(mimeType)) { return encoders[j]; } } return null ; } //GetEncoderInfo } //Example_SetColorDepth

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からEncoder.ColorDepth フィールドを検索する場合は、下記のリンクをクリックしてください。

- Encoder.ColorDepth フィールドのページへのリンク