// 32ビットBMPファイルを読み込んで24ビットBMPファイルとして保存する private void bitmapFrom32To24(string loadFileName, string saveFileName) { Bitmap bmpFile1; Bitmap bmpFile2; // XNAで保存した32ビットBMPファイルを読み込む bmpFile1 = (Bitmap)Bitmap.FromFile(loadFileName); // 24ビットBMPを作成する bmpFile2 = new Bitmap(bmpFile1.Width, bmpFile1.Height, PixelFormat.Format24bppRgb); // 32ビットBMPから24ビットBMPに1ピクセル単位でコピーする for (int y = 0; y < bmpFile1.Height; y++) for (int x = 0; x < bmpFile1.Width; x++) // bmpFile2.SetPixel(x, y, System.Drawing.Color.FromArgb(255, bmpFile1.GetPixel(x, y))); bmpFile2.SetPixel(x, y, bmpFile1.GetPixel(x, y)); // BMPファイルを保存する bmpFile2.Save(saveFileName, ImageFormat.Bmp); // ファイルがロックされているので解放する bmpFile1.Dispose(); bmpFile2.Dispose(); }