summaryrefslogtreecommitdiff
path: root/src/WNT/WNT_Image.cxx
blob: db82b159885bb521635f71b36a5a749bb09b8660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// File:      WNT_Image.cxx
// Copyright: Open Cascade 2008

// include windows.h first to have all definitions available
#include <windows.h>
#include <WNT_Image.ixx>

#include <W32_Allocator.hxx>

//=======================================================================
//function : WNT_Image
//purpose  : 
//=======================================================================

WNT_Image::WNT_Image ( const Aspect_Handle aBitmap,
                       const Standard_Integer aHashCode )
{

  myImage = ( Standard_Address )HeapAlloc (
                                GetProcessHeap (),
                                HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS,
                                sizeof ( WNT_Bitmap )
                               );
 
  (  ( PW32_Bitmap )myImage ) -> hBmp  = ( ::HBITMAP )aBitmap;
  (  ( PW32_Bitmap )myImage ) -> nUsed = 1;
  myHashCode                           = aHashCode;

}  // end constructor

//=======================================================================
//function : Destroy
//purpose  : 
//=======================================================================

void WNT_Image::Destroy () {

  if (  --(  ( PW32_Bitmap )myImage  ) -> nUsed == 0 &&
          (  ( PW32_Bitmap )myImage  ) -> hBmp  != NULL
 ) {
 
    DeleteObject (   (  ( PW32_Bitmap )myImage  ) -> hBmp   );
    HeapFree (  GetProcessHeap (), 0, ( PVOID )myImage  );

  }  // end if

}  // end WNT_Image :: Destroy