回答編集履歴
1
少し修正
answer
CHANGED
@@ -97,7 +97,7 @@
|
|
97
97
|
|
98
98
|
private Bitmap ConvertBmp8(Bitmap bmp)
|
99
99
|
{
|
100
|
-
|
100
|
+
//出力用8bitビットマップ
|
101
101
|
var bmp8 = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
|
102
102
|
|
103
103
|
//GetDIBitsで8bitビットマップ取得
|
@@ -109,6 +109,7 @@
|
|
109
109
|
bi.bmiHeader.biBitCount = 8;
|
110
110
|
bi.bmiHeader.biCompression = BitmapCompressionMode.BI_RGB;
|
111
111
|
var hdc = CreateCompatibleDC(IntPtr.Zero);
|
112
|
+
var hBmp = bmp.GetHbitmap();
|
112
113
|
var hBmpOld = SelectObject(hdc, hBmp);
|
113
114
|
var bmData = bmp8.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
|
114
115
|
GetDIBits(hdc, hBmp, 0, bmp.Height, bmData.Scan0, ref bi, DibColorsUsage.RGB);
|