Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Thumbnail.cpp
Go to the documentation of this file.
1 /* Project Magic 2.0
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Magic.exe
6  FILE: Thumbnail.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Thumbnail.cpp : implementation file
13 */
14 
15 #include "stdafx.h"
16 #include "Bitmap.h"
17 
18 // +--------------------------------------------------------------------+
19 // Preview a bitmap image in the desired window
20 // +--------------------------------------------------------------------+
21 
22 void ThumbPreview(HWND hprev, Bitmap* bitmap)
23 {
24  HDC hdc = ::GetDC(hprev);
25  RECT rect;
26  BITMAPINFO* pbmiDIB = new BITMAPINFO;
27 
28  if (!pbmiDIB)
29  return;
30 
31  ::GetClientRect(hprev, &rect);
32 
33  pbmiDIB->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
34  pbmiDIB->bmiHeader.biWidth = bitmap->Width();
35  pbmiDIB->bmiHeader.biHeight = -bitmap->Height();
36  pbmiDIB->bmiHeader.biPlanes = 1;
37  pbmiDIB->bmiHeader.biBitCount = 32;
38  pbmiDIB->bmiHeader.biCompression = BI_RGB;
39  pbmiDIB->bmiHeader.biSizeImage = 0;
40  pbmiDIB->bmiHeader.biXPelsPerMeter = 0;
41  pbmiDIB->bmiHeader.biYPelsPerMeter = 0;
42  pbmiDIB->bmiHeader.biClrUsed = 0;
43  pbmiDIB->bmiHeader.biClrImportant = 0;
44 
45  int result =
46  ::StretchDIBits(hdc,
47  1, 1, 128, 128,
48  0, 0, bitmap->Width(), bitmap->Height(),
49  bitmap->HiPixels(),
50  pbmiDIB,
51  DIB_RGB_COLORS,
52  SRCCOPY);
53 
54  ::ReleaseDC(hprev, hdc);
55 
56  delete pbmiDIB;
57 }