質問編集履歴

3

Edit title

2019/04/14 13:53

投稿

Weapon
Weapon

スコア106

test CHANGED
@@ -1 +1 @@
1
- WinAPI BITMAPを読み込んでBITMAPの描画UI
1
+ WinAPI BITMAPを読み込んでBITMAPの描画UI
test CHANGED
File without changes

2

IDE's version up

2019/04/14 13:53

投稿

Weapon
Weapon

スコア106

test CHANGED
File without changes
test CHANGED
@@ -590,4 +590,4 @@
590
590
 
591
591
  Windows10 Pro
592
592
 
593
- VisualStudio2017 Community
593
+ VisualStudio2019 Community

1

コメント追加・本文修正

2019/04/14 13:46

投稿

Weapon
Weapon

スコア106

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- BMPをウィンドウにドロップするとファイルヘッダ―等を読み取って情報を画像とともに表示するコードを書いています.圧縮の有無判別はまだしていませんからかなり荒いですが画像の表示ができません.また文字の表示が一回上書きされてしまいドロップ時に文字列が表示されません.画像のデータの取得ミスのように思いますがお願いします.
3
+ BMPをウィンドウにドロップするとファイルヘッダ―等を読み取って情報を画像とともに表示するコードを書いています.圧縮の有無判別はまだしていませんからかなり荒いですが画像の表示ができません.~~また文字の表示が一回上書きされてしまいドロップ時に文字列が表示されません.~~ ~~画像のデータの取得ミスのように思いますがお願いします.~~
4
4
 
5
5
 
6
6
 
@@ -8,6 +8,14 @@
8
8
 
9
9
 
10
10
 
11
+ ### 修正および追記
12
+
13
+ WM_PAINT周辺は変更したつもりですが223行目のポインターに代入すると例外が投げられます.引数のbitmapのSizeiImageを再代入してみたりしましたが私のデバッグの知識ではそれ以上把握できませんでした.画像の描画領域の確保まではいけていると思いますが画像が表示できません.
14
+
15
+ GetDCをWM_CREATEで入手していいものかその辺りの変なところもご指摘お願いします.
16
+
17
+
18
+
11
19
  ### 該当のソースコード
12
20
 
13
21
 
@@ -66,7 +74,7 @@
66
74
 
67
75
  HWND hwnd = CreateWindowEx(
68
76
 
69
- WS_EX_ACCEPTFILES, CLASS_NAME, L"BitMap Binaly Analyzer", WS_OVERLAPPEDWINDOW,
77
+ WS_EX_ACCEPTFILES, CLASS_NAME, L"Template", WS_OVERLAPPEDWINDOW,
70
78
 
71
79
  50, 50, 960, 525,
72
80
 
@@ -104,35 +112,45 @@
104
112
 
105
113
  LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
106
114
 
107
- static BOOL opened = FALSE;
115
+ static BOOL status_b_open = FALSE;
116
+
117
+ static DWORD status_d_head = 0;
118
+
119
+
108
120
 
109
121
  static wchar_t filename[_MAX_PATH] = { 0 };
110
122
 
123
+
124
+
125
+ static RECT rc = { 0, 0, 0, 0 };
126
+
127
+ static RECT src = { 5, 5, 0, 0 };
128
+
129
+ static BITMAPFILEHEADER bmfh;
130
+
131
+ static BITMAPV5HEADER* bmih;
132
+
133
+
134
+
135
+
136
+
137
+ static HDC hdc;
138
+
139
+ static HDC hBuffer;
140
+
141
+ static HBITMAP hbmp;
142
+
111
143
  static HANDLE hFile;
112
144
 
145
+ static HBITMAP bm;
146
+
147
+
148
+
149
+
150
+
113
151
  static BYTE* filedata;
114
152
 
115
- static LPDWORD rfilesize;
116
-
117
- static RECT rc;
118
-
119
- static RECT src = { 5,5,0,0 };
120
-
121
- static BITMAPFILEHEADER input;
122
-
123
- static BITMAPV5HEADER *bmi = { 0 };
124
-
125
- static HBITMAP hbmp;
126
-
127
- static HDC hbuffer;
128
-
129
- static void *pv;
153
+ static void* pv;
130
-
131
- static HDC hdc;
132
-
133
- static BITMAP bm;
134
-
135
-
136
154
 
137
155
  static wchar_t pstring[4096];
138
156
 
@@ -140,25 +158,49 @@
140
158
 
141
159
  switch (uMsg) {
142
160
 
161
+ case WM_CREATE:
162
+
163
+ hdc = GetDC(hwnd);
164
+
165
+ break;
166
+
167
+
168
+
169
+ case WM_PAINT:
170
+
171
+ {
172
+
173
+ if (status_b_open == TRUE) {
174
+
175
+ if (StretchBlt(hdc, 250, 50, bmih->bV5Width / 2, bmih->bV5Height / 2, hBuffer, 0, 0, bmih->bV5Width, bmih->bV5Height, SRCCOPY) == FALSE) {
176
+
177
+ MessageBox(hwnd, L"Failed to drawtext", L"CAUTION", MB_OK);
178
+
179
+ }
180
+
181
+ }
182
+
143
183
 
144
184
 
185
+ DrawText(hdc, pstring, -1, &src, DT_LEFT | DT_TOP);
186
+
187
+
188
+
145
- case WM_CREATE:
189
+ ValidateRect(hwnd, NULL);
190
+
146
-
191
+ }
192
+
147
- break;
193
+ break;
148
-
149
-
150
-
194
+
151
- case WM_PAINT:
195
+ case WM_SIZE:
152
196
 
153
197
  {
154
198
 
155
- hdc = GetDC(hwnd);
199
+ GetClientRect(hwnd, &rc);
156
-
157
- BOOL a= StretchBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdc, 200, 50, bm.bmWidth / 2, bm.bmHeight / 2, SRCCOPY);
200
+
158
-
159
- if (a == FALSE)MessageBox(hwnd, L"FAILED TO SB", L"CAUTION", MB_OK);
201
+ src.right = rc.right;
160
-
202
+
161
- DrawText(hdc, pstring, -1, &src, DT_WORDBREAK);
203
+ src.bottom = rc.bottom;
162
204
 
163
205
  }
164
206
 
@@ -166,346 +208,364 @@
166
208
 
167
209
 
168
210
 
211
+
212
+
169
213
  case WM_DROPFILES:
170
214
 
171
215
  {
172
216
 
217
+ /* temporary param */
218
+
219
+ LPDWORD rfsize=0;
220
+
173
- if (opened == TRUE) {
221
+ wchar_t tbmp[64] = { 0 };
222
+
174
-
223
+ wchar_t infoheadstatus[32] = { 0 };
224
+
225
+ wchar_t getStatus[1025] = { 0 };
226
+
227
+ /* End temporary param */
228
+
229
+
230
+
231
+ /* Get Droped File */
232
+
233
+ wchar_t openedfilename[_MAX_PATH] = { 0 };
234
+
235
+ wcscpy_s(openedfilename, _MAX_PATH, filename);
236
+
237
+ HDROP hDrop = (HDROP)wParam;
238
+
239
+ unsigned cof = DragQueryFile(hDrop, -1, NULL, 0);
240
+
241
+ if (cof == -1)MessageBox(hwnd, L"This application arrowed only 1 file at the same time", L"CAUTION", MB_OK);//alert when i get plural files -> get the first file
242
+
243
+ DragQueryFile(hDrop, 0, filename, _MAX_PATH);
244
+
245
+ /* End Get Droped File */
246
+
247
+
248
+
249
+
250
+
251
+ if (wcscmp(filename, openedfilename) != 0) {//process when the droped file is different with before one
252
+
253
+
254
+
255
+ /* Copy File */
256
+
257
+ hFile = CreateFile(filename, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
258
+
259
+
260
+
261
+ size_t fsize = GetFileSize(hFile, NULL);
262
+
263
+ rfsize = 0;
264
+
265
+ filedata = (BYTE*)malloc(fsize);
266
+
267
+ if (ReadFile(hFile, filedata, fsize, rfsize, NULL) == FALSE) {
268
+
175
- if (MessageBox(hwnd, L"Replace this image?", L"CAUTION", MB_YESNO) == IDNO)break;
269
+ MessageBox(hwnd, L"FAILED TO READ", L"CAUTION", MB_OK);
176
-
177
- else {
270
+
178
-
179
- ZeroMemory(filename, _MAX_PATH * 2);
180
-
181
- CloseHandle(hFile);
182
-
183
- rfilesize = NULL;
271
+ return -1;
184
-
185
- if (filedata != NULL)free(filedata);
186
272
 
187
273
  }
188
274
 
189
-
190
-
191
- }else opened = TRUE;
192
-
193
-
194
-
195
- HDROP hDrop = (HDROP)wParam;
196
-
197
- unsigned cof = DragQueryFile(hDrop, -1, NULL, 0);
198
-
199
- if (cof != 1)MessageBox(hwnd, L"This application arrowed only 1 file at the same time", L"CAUTION", MB_OK);
200
-
201
- DragQueryFile(hDrop, 0, filename, _MAX_PATH);
202
-
203
- hFile = CreateFile(filename, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
204
-
205
-
206
-
207
- size_t fsize = GetFileSize(hFile, NULL);
208
-
209
- filedata = (BYTE*)malloc(fsize);
210
-
211
- if (ReadFile(hFile, filedata, fsize, rfilesize, NULL) == FALSE) {
212
-
213
- MessageBox(hwnd, L"FAILED TO READ", L"CAUTION", MB_OK);
214
-
215
- return -1;
275
+ /* End Copy File */
276
+
277
+
278
+
279
+ /* Get Magic Number */
280
+
281
+ DWORD dwHead = filedata[0] << 8 | filedata[1];
282
+
283
+
284
+
285
+ size_t hotspotx = filedata[6] << 8 | filedata[7];
286
+
287
+ size_t hotspoty = filedata[8] << 8 | filedata[9];
288
+
289
+
290
+
291
+ DWORD wsize = 0;
292
+
293
+ switch (dwHead) {
294
+
295
+ case 'BM':
296
+
297
+ {
298
+
299
+ int* s = (int*)(filedata + 0xe);
300
+
301
+ if (hotspotx == 0 && hotspoty == 0 && *s != 12) {
302
+
303
+ wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.1");
304
+
305
+ status_d_head = 0x100;
306
+
307
+ }
308
+
309
+ else {
310
+
311
+ wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.2");
312
+
313
+ status_d_head = 0x200;
314
+
315
+ }
316
+
317
+
318
+
319
+ wsize = filedata[2] | filedata[3] << 8 | filedata[4] << 16 | filedata[5] << 24;
320
+
321
+ }
322
+
323
+ break;
324
+
325
+
326
+
327
+ case 'IC':
328
+
329
+ case 'CI':
330
+
331
+ case 'PT':
332
+
333
+ case 'CP':
334
+
335
+ if (hotspotx != 0 && hotspoty != 0) {
336
+
337
+ wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.2");
338
+
339
+ status_d_head = 0x200;
340
+
341
+ wsize = filedata[2] | filedata[3] << 8 | filedata[4] << 16 | filedata[5] << 24;
342
+
343
+ break;
344
+
345
+ }
346
+
347
+ else {
348
+
349
+ wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.2 but not use hotspot");
350
+
351
+ status_d_head = 0x200;
352
+
353
+ wsize = 0;
354
+
355
+ break;
356
+
357
+ }
358
+
359
+ default:
360
+
361
+ wsprintf(tbmp, L"not BMP file");
362
+
363
+ wsize = 0;
364
+
365
+ status_d_head = 0x0;
366
+
367
+ }
368
+
369
+ /* End Get Magic Number */
370
+
371
+
372
+
373
+
374
+
375
+ /* Check File version and Fill defined structure */
376
+
377
+ /* Remark : If the file is classified as Bitmap for Windows, i read the file data */
378
+
379
+
380
+
381
+
382
+
383
+ size_t tableoff = filedata[0xa] | filedata[0xb] << 8 | filedata[0xc] << 16 | filedata[0xd] << 24;//the offset of the table lead from the file lead
384
+
385
+ size_t infosize = filedata[0xe] | filedata[0xf] << 8 | filedata[0x10] << 16 | filedata[0x11] << 24;//size of header
386
+
387
+
388
+
389
+ switch (status_d_head) {
390
+
391
+ case 0x100:
392
+
393
+ {
394
+
395
+ switch (infosize) {
396
+
397
+ case 40:
398
+
399
+ wsprintf(infoheadstatus, L"version.1 for Win");
400
+
401
+ bmih = (BITMAPV5HEADER*)(filedata + 0xe);
402
+
403
+ wsprintf(getStatus, L"biSize : %d\nbiWidth : %d\nbiHeight : %d\nbiPlanes : %d\nbiBitCount : %d\nbiCompression : %d\nbiSizeImage : %d\nbiXPelsPerMeter : %d\nbiYPelsPerMeter : %d\nbiClrUsed : %d\nbiClrImportant : %d\n\0", bmih->bV5Size, bmih->bV5Width, bmih->bV5Height, bmih->bV5Planes, bmih->bV5BitCount, bmih->bV5Compression, bmih->bV5SizeImage, bmih->bV5XPelsPerMeter, bmih->bV5YPelsPerMeter, bmih->bV5ClrUsed, bmih->bV5ClrImportant);
404
+
405
+ status_d_head |= 0x1;
406
+
407
+
408
+
409
+ break;
410
+
411
+ case 108:
412
+
413
+ wsprintf(infoheadstatus, L"version.4");
414
+
415
+ bmih = (BITMAPV5HEADER*)(filedata + 0xe);
416
+
417
+ wsprintf(getStatus, L"bV4Size : %d\nbV4Width : %d\nbV4Height : %d\nbV4Planes : %d\nbV4bV4tCount : %d\nbV4Compression : %d\nbV4SizeImage : %d\nbV4XPelsPerMeter : %d\nbV4YPelsPerMeter : %d\nbV4ClrUsed : %d\nbV4ClrImportant : %d\nbV4RedMask : %d\nbV4GreenMask : %d\nbV4BlueMask : %d\nbV4AlphaMask : %d\nbV4CSType : %d\nbV4Endpoints : %p\nbV4GammaRed : %d\nbV4GammaGreen : %d\nbV4GammaBlue : %d\n\0", bmih->bV5Size, bmih->bV5Width, bmih->bV5Height, bmih->bV5Planes, bmih->bV5BitCount, bmih->bV5Compression, bmih->bV5SizeImage, bmih->bV5XPelsPerMeter, bmih->bV5YPelsPerMeter, bmih->bV5ClrUsed, bmih->bV5ClrImportant, bmih->bV5RedMask, bmih->bV5GreenMask, bmih->bV5BlueMask, bmih->bV5AlphaMask, bmih->bV5CSType, bmih->bV5Endpoints, bmih->bV5GammaRed, bmih->bV5GammaGreen, bmih->bV5GammaBlue);
418
+
419
+ status_d_head |= 0x2;
420
+
421
+
422
+
423
+ break;
424
+
425
+
426
+
427
+ case 124:
428
+
429
+ wsprintf(infoheadstatus, L"version.5");
430
+
431
+ bmih = (BITMAPV5HEADER*)(filedata + 0xe);
432
+
433
+ wsprintf(getStatus, L"bV5Size : %d\nbV5Width : %d\nbV5Height : %d\nbV5Planes : %d\nbV5BitCount : %d\nbV5Compression : %d\nbV5SizeImage : %d\nbV5XPelsPerMeter : %d\nbV5YPelsPerMeter : %d\nbV5ClrUsed : %d\nbV5ClrImportant : %d\nbV5RedMask : %d\nbV5GreenMask : %d\nbV5BlueMask : %d\nbV5AlphaMask : %d\nbV5CSType : %d\nbV5Endpoints : %p\nbV5GammaRed : %d\nbV5GammaGreen : %d\nbV5GammaBlue : %d\nbV5Intent : %d\nbV5ProfileData : %d\nbV5ProfileSize : %d\nbV5Reserved%d\n\0", bmih->bV5Size, bmih->bV5Width, bmih->bV5Height, bmih->bV5Planes, bmih->bV5BitCount, bmih->bV5Compression, bmih->bV5SizeImage, bmih->bV5XPelsPerMeter, bmih->bV5YPelsPerMeter, bmih->bV5ClrUsed, bmih->bV5ClrImportant, bmih->bV5RedMask, bmih->bV5GreenMask, bmih->bV5BlueMask, bmih->bV5AlphaMask, bmih->bV5CSType, (tagICEXYZTRIPLE)bmih->bV5Endpoints, bmih->bV5GammaRed, bmih->bV5GammaGreen, bmih->bV5GammaBlue, bmih->bV5Intent, bmih->bV5ProfileData, bmih->bV5ProfileSize, bmih->bV5Reserved);
434
+
435
+ status_d_head |= 0x3;
436
+
437
+
438
+
439
+ break;
440
+
441
+
442
+
443
+ default:
444
+
445
+ wsprintf(infoheadstatus, L"BROKEN BMP");
446
+
447
+
448
+
449
+ goto FileCheckEnd;
450
+
451
+ }
452
+
453
+
454
+
455
+ /* Image Rendering */
456
+
457
+
458
+
459
+ hBuffer = CreateCompatibleDC(hdc);
460
+
461
+
462
+
463
+ hbmp = CreateDIBSection(hBuffer, (BITMAPINFO*)bmih, DIB_RGB_COLORS, &pv, NULL, NULL);
464
+
465
+ if (hbmp != NULL) {
466
+
467
+ int bmpoffset = bmfh.bfOffBits;
468
+
469
+ for (int i = 0; i < bmih->bV5Height * bmih->bV5Width; i++)((unsigned *)pv)[i] = filedata[bmpoffset+i];
470
+
471
+
472
+
473
+ SelectObject(hBuffer, hbmp);
474
+
475
+ GetObject(hBuffer, sizeof(BITMAP), &bm);
476
+
477
+
478
+
479
+ status_b_open = TRUE;
480
+
481
+
482
+
483
+ }
484
+
485
+ else {
486
+
487
+ MessageBox(hwnd, L"FAILED TO CDIBS", L"CAUTION", MB_OK);
488
+
489
+ status_b_open = FALSE;
490
+
491
+ }
492
+
493
+
494
+
495
+ /* End Image Rendering */
496
+
497
+
498
+
499
+
500
+
501
+ }
502
+
503
+ break;
504
+
505
+
506
+
507
+ case 0x200:
508
+
509
+ if (infosize == 12) {
510
+
511
+ wsprintf(infoheadstatus, L"core for OS/2");
512
+
513
+ }
514
+
515
+ else if (infosize >= 16 && infosize <= 64) {
516
+
517
+ wsprintf(infoheadstatus, L"version.2 for OS/2");
518
+
519
+ }
520
+
521
+ else {
522
+
523
+ wsprintf(infoheadstatus, L"BROKEN BMP for OS/2");
524
+
525
+ }
526
+
527
+ status_b_open = FALSE;
528
+
529
+ break;
530
+
531
+
532
+
533
+ default:
534
+
535
+ wsprintf(infoheadstatus, L"NO INFOHEADER");
536
+
537
+ status_b_open = FALSE;
538
+
539
+ }
216
540
 
217
541
  }
218
542
 
219
-
220
-
221
- wchar_t tbmp[64] = { 0 };
222
-
223
- DWORD dwHead = filedata[0] << 8 | filedata[1];
224
-
225
- DWORD wsize = 0;
226
-
227
-
228
-
229
- size_t hotspotx = filedata[6] << 8 | filedata[7];
230
-
231
- size_t hotspoty = filedata[8] << 8 | filedata[9];
232
-
233
-
234
-
235
- int bitmapfileheaderver = 0;
236
-
237
-
238
-
239
- switch (dwHead) {
240
-
241
- case 'BM':
242
-
243
- {
244
-
245
- int *s = (int*)(filedata + 0xe);
246
-
247
- if (hotspotx == 0 && hotspoty == 0 && *s != 12) {
248
-
249
- wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.1");
250
-
251
- bitmapfileheaderver = 1;
252
-
253
- }
254
-
255
- else {
256
-
257
- wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.2");
258
-
259
- bitmapfileheaderver = 2;
260
-
261
- }
262
-
263
-
264
-
265
- wsize = filedata[2] | filedata[3] << 8 | filedata[4] << 16 | filedata[5] << 24;
266
-
267
- }
268
-
269
- break;
270
-
271
-
272
-
273
- case 'IC':
274
-
275
- case 'CI':
276
-
277
- case 'PT':
278
-
279
- case 'CP':
280
-
281
- if (hotspotx != 0 && hotspoty != 0) {
282
-
283
- wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.2");
284
-
285
- bitmapfileheaderver = 2;
286
-
287
- wsize = filedata[2] | filedata[3] << 8 | filedata[4] << 16 | filedata[5] << 24;
288
-
289
- break;
290
-
291
- }
292
-
293
- else {
294
-
295
- wsprintf(tbmp, L"BMP file\nBITMAPFILEHEADER : version.2 but not use hotspot");
296
-
297
- bitmapfileheaderver = 2;
298
-
299
- wsize = 0;
300
-
301
- break;
302
-
303
- }
304
-
305
- default:
306
-
307
- wsprintf(tbmp, L"not BMP file");
308
-
309
- wsize = 0;
310
-
311
- bitmapfileheaderver = 0;
312
-
313
- }
314
-
315
- //READ ABOUT OS/2 BMP
316
-
317
-
318
-
319
- size_t tableoff = filedata[0xa] | filedata[0xb] << 8 | filedata[0xc] << 16 | filedata[0xd] << 24;
320
-
321
-
322
-
323
- size_t infosize = filedata[0xe] | filedata[0xf] << 8 | filedata[0x10] << 16 | filedata[0x11] << 24;
324
-
325
-
326
-
327
- wchar_t infoheadstatus[32] = { 0 };
328
-
329
- wchar_t getStatus[1025] = { 0 };
330
-
331
-
332
-
333
-
334
-
335
- int bitmapinfoheaderver = 0;
336
-
337
- switch (bitmapfileheaderver) {
338
-
339
- case 1:
340
-
341
- {
342
-
343
- switch (infosize) {
344
-
345
- case 40:
346
-
347
- wsprintf(infoheadstatus, L"version.1 for Win");
348
-
349
- bmi = (BITMAPV5HEADER*)(filedata + 0xe);
350
-
351
- wsprintf(getStatus, L"biSize : %d\nbiWidth : %d\nbiHeight : %d\nbiPlanes : %d\nbiBitCount : %d\nbiCompression : %d\nbiSizeImage : %d\nbiXPelsPerMeter : %d\nbiYPelsPerMeter : %d\nbiClrUsed : %d\nbiClrImportant : %d\n\0", bmi->bV5Size, bmi->bV5Width, bmi->bV5Height, bmi->bV5Planes, bmi->bV5BitCount, bmi->bV5Compression, bmi->bV5SizeImage, bmi->bV5XPelsPerMeter, bmi->bV5YPelsPerMeter, bmi->bV5ClrUsed, bmi->bV5ClrImportant);
352
-
353
- bitmapinfoheaderver = 1;
354
-
355
-
356
-
357
- break;
358
-
359
- case 108:
360
-
361
- wsprintf(infoheadstatus, L"version.4");
362
-
363
- bmi = (BITMAPV5HEADER*)(filedata + 0xe);
364
-
365
- wsprintf(getStatus, L"bV4Size : %d\nbV4Width : %d\nbV4Height : %d\nbV4Planes : %d\nbV4bV4tCount : %d\nbV4Compression : %d\nbV4SizeImage : %d\nbV4XPelsPerMeter : %d\nbV4YPelsPerMeter : %d\nbV4ClrUsed : %d\nbV4ClrImportant : %d\nbV4RedMask : %d\nbV4GreenMask : %d\nbV4BlueMask : %d\nbV4AlphaMask : %d\nbV4CSType : %d\nbV4Endpoints : %p\nbV4GammaRed : %d\nbV4GammaGreen : %d\nbV4GammaBlue : %d\n\0", bmi->bV5Size, bmi->bV5Width, bmi->bV5Height, bmi->bV5Planes, bmi->bV5BitCount, bmi->bV5Compression, bmi->bV5SizeImage, bmi->bV5XPelsPerMeter, bmi->bV5YPelsPerMeter, bmi->bV5ClrUsed, bmi->bV5ClrImportant, bmi->bV5RedMask, bmi->bV5GreenMask, bmi->bV5BlueMask, bmi->bV5AlphaMask, bmi->bV5CSType, bmi->bV5Endpoints, bmi->bV5GammaRed, bmi->bV5GammaGreen, bmi->bV5GammaBlue);
366
-
367
- bitmapinfoheaderver = 4;
368
-
369
-
370
-
371
- break;
372
-
373
-
374
-
375
- case 124:
376
-
377
- wsprintf(infoheadstatus, L"version.5");
378
-
379
- bmi = (BITMAPV5HEADER*)(filedata + 0xe);
380
-
381
- wsprintf(getStatus, L"bV5Size : %d\nbV5Width : %d\nbV5Height : %d\nbV5Planes : %d\nbV5BitCount : %d\nbV5Compression : %d\nbV5SizeImage : %d\nbV5XPelsPerMeter : %d\nbV5YPelsPerMeter : %d\nbV5ClrUsed : %d\nbV5ClrImportant : %d\nbV5RedMask : %d\nbV5GreenMask : %d\nbV5BlueMask : %d\nbV5AlphaMask : %d\nbV5CSType : %d\nbV5Endpoints : %p\nbV5GammaRed : %d\nbV5GammaGreen : %d\nbV5GammaBlue : %d\nbV5Intent : %d\nbV5ProfileData : %d\nbV5ProfileSize : %d\nbV5Reserved%d\n\0", bmi->bV5Size, bmi->bV5Width, bmi->bV5Height, bmi->bV5Planes, bmi->bV5BitCount, bmi->bV5Compression, bmi->bV5SizeImage, bmi->bV5XPelsPerMeter, bmi->bV5YPelsPerMeter, bmi->bV5ClrUsed, bmi->bV5ClrImportant, bmi->bV5RedMask, bmi->bV5GreenMask, bmi->bV5BlueMask, bmi->bV5AlphaMask, bmi->bV5CSType, bmi->bV5Endpoints, bmi->bV5GammaRed, bmi->bV5GammaGreen, bmi->bV5GammaBlue, bmi->bV5Intent, bmi->bV5ProfileData, bmi->bV5ProfileSize, bmi->bV5Reserved);
382
-
383
- bitmapinfoheaderver = 5;
384
-
385
-
386
-
387
- break;
388
-
389
-
390
-
391
- default:
392
-
393
- wsprintf(infoheadstatus, L"BROKEN BMP");
394
-
395
-
396
-
397
- goto FileCheckEnd;
398
-
399
- }
400
-
401
-
402
-
403
- hbmp = CreateDIBSection(NULL, (BITMAPINFO*)bmi, DIB_RGB_COLORS, &pv, NULL, NULL);
404
-
405
-
406
-
407
- int* imgofst = (int*)(filedata+10);
408
-
409
-
410
-
411
- pv = (void*)filedata[*imgofst];
412
-
413
-
414
-
415
- if (hbmp == NULL)MessageBox(hwnd, L"FAILED TO CDIBS", L"CAUTION", MB_OK);
416
-
417
- hbuffer = CreateCompatibleDC(hdc);
418
-
419
- SelectObject(hbuffer, hbmp);
420
-
421
- GetObject(hbuffer, sizeof(BITMAP), &bm);
422
-
423
-
424
-
425
- }
426
-
427
- break;
428
-
429
-
430
-
431
- case 2:
432
-
433
- if (infosize == 12) {
434
-
435
- wsprintf(infoheadstatus, L"core for OS/2");
436
-
437
- }
438
-
439
- else if (infosize >= 16 && infosize <= 64) {
440
-
441
- wsprintf(infoheadstatus, L"version.2 for OS/2");
442
-
443
- }
444
-
445
- else {
446
-
447
- wsprintf(infoheadstatus, L"BROKEN BMP for OS/2");
448
-
449
- }
450
-
451
- break;
452
-
453
-
454
-
455
- default:
456
-
457
- wsprintf(infoheadstatus, L"NO INFOHEADER");
458
-
459
- }
460
-
461
-
462
-
463
- FileCheckEnd:
464
-
465
-
466
-
467
- ZeroMemory(pstring, 2 * 4096);
468
-
469
-
470
-
471
- wsprintf(pstring, L"PATH : %s\n\nFileSize : %10dbyte\nMagic Number : %c%c %s\n\nWrittenfileSize : %10dbyte\nBITMAPINFOHEADER : %s\n\0", filename, fsize, filedata[0], filedata[1], tbmp, wsize, infoheadstatus);
472
-
473
-
474
-
475
- if ((bitmapinfoheaderver >= 1) && (bitmapinfoheaderver != 0)) {
476
-
477
- wcscat_s(pstring, 1024 * 2, getStatus);
478
-
479
- }
480
-
481
- InvalidateRect(hwnd, NULL, TRUE);
482
-
483
- UpdateWindow(hwnd);
543
+ /* End Check File version and Fill defined structure */
544
+
545
+
546
+
547
+ /* Pass the string data to the parameter of parent scope */
548
+
549
+ wsprintf(pstring, L"PATH : %s\n\nFileType : \n%s\n\nInfoHeader : \n%s\n", filename, tbmp, getStatus);
550
+
551
+ /* Pass the string data to the parameter of parent scope */
552
+
553
+
484
554
 
485
555
  }
486
556
 
557
+ FileCheckEnd:
558
+
559
+
560
+
561
+ InvalidateRect(hwnd, NULL, TRUE);
562
+
487
563
  break;
488
564
 
489
565
 
490
566
 
491
- case WM_SIZE:
492
-
493
- GetClientRect(hwnd, &rc);
494
-
495
- src.right = rc.right - 5;
496
-
497
- src.bottom = rc.bottom - 5;
498
-
499
- break;
500
-
501
-
502
-
503
567
  case WM_DESTROY:
504
568
 
505
- CloseHandle(hFile);
506
-
507
- free(filedata);
508
-
509
569
  PostQuitMessage(0);
510
570
 
511
571
  return 0;