回答編集履歴
1
少し修正
test
CHANGED
@@ -196,30 +196,32 @@
|
|
196
196
|
|
197
197
|
{
|
198
198
|
|
199
|
+
//出力用8bitビットマップ
|
200
|
+
|
201
|
+
var bmp8 = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
//GetDIBitsで8bitビットマップ取得
|
206
|
+
|
207
|
+
BITMAPINFO bi = new BITMAPINFO();
|
208
|
+
|
209
|
+
bi.bmiHeader.biSize = (uint)Marshal.SizeOf(bi.bmiHeader);
|
210
|
+
|
211
|
+
bi.bmiHeader.biWidth = bmp.Width;
|
212
|
+
|
213
|
+
bi.bmiHeader.biHeight = -bmp.Height; //トップダウンにするためマイナス(上下逆転する)
|
214
|
+
|
215
|
+
bi.bmiHeader.biPlanes = 1;
|
216
|
+
|
217
|
+
bi.bmiHeader.biBitCount = 8;
|
218
|
+
|
219
|
+
bi.bmiHeader.biCompression = BitmapCompressionMode.BI_RGB;
|
220
|
+
|
221
|
+
var hdc = CreateCompatibleDC(IntPtr.Zero);
|
222
|
+
|
199
223
|
var hBmp = bmp.GetHbitmap();
|
200
224
|
|
201
|
-
var bmp8 = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
//GetDIBitsで8bitビットマップ取得
|
206
|
-
|
207
|
-
BITMAPINFO bi = new BITMAPINFO();
|
208
|
-
|
209
|
-
bi.bmiHeader.biSize = (uint)Marshal.SizeOf(bi.bmiHeader);
|
210
|
-
|
211
|
-
bi.bmiHeader.biWidth = bmp.Width;
|
212
|
-
|
213
|
-
bi.bmiHeader.biHeight = -bmp.Height; //トップダウンにするためマイナス(上下逆転する)
|
214
|
-
|
215
|
-
bi.bmiHeader.biPlanes = 1;
|
216
|
-
|
217
|
-
bi.bmiHeader.biBitCount = 8;
|
218
|
-
|
219
|
-
bi.bmiHeader.biCompression = BitmapCompressionMode.BI_RGB;
|
220
|
-
|
221
|
-
var hdc = CreateCompatibleDC(IntPtr.Zero);
|
222
|
-
|
223
225
|
var hBmpOld = SelectObject(hdc, hBmp);
|
224
226
|
|
225
227
|
var bmData = bmp8.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
|