Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ImgView.cpp
Go to the documentation of this file.
1 /* Project nGenEx
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: nGenEx.lib
6  FILE: ImgView.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Bitmap "billboard" Image View class
13 */
14 
15 #include "MemDebug.h"
16 #include "ImgView.h"
17 #include "Color.h"
18 #include "Window.h"
19 #include "Video.h"
20 #include "Bitmap.h"
21 #include "Screen.h"
22 
23 // +--------------------------------------------------------------------+
24 
26 : View(c), img(bmp), width(0), height(0), x_offset(0), y_offset(0),
27 blend(Video::BLEND_SOLID)
28 {
29  if (img) {
30  width = img->Width();
31  height = img->Height();
32  }
33 
34  if (width < c->Width())
35  x_offset = (c->Width() - width) / 2;
36 
37  if (height < c->Height())
38  y_offset = (c->Height() - height) / 2;
39 }
40 
42 {
43 }
44 
45 // +--------------------------------------------------------------------+
46 
47 void
49 {
50  if (img && width > 0 && height > 0)
52  y_offset,
53  x_offset + width,
54  y_offset + height,
55  img,
56  blend);
57 }
58 
59 // +--------------------------------------------------------------------+
60 
61 void
63 {
64  img = bmp;
65  width = 0;
66  height = 0;
67  x_offset = 0;
68  y_offset = 0;
69 
70  if (img) {
71  width = img->Width();
72  height = img->Height();
73  }
74 
75  if (window) {
76  x_offset = (window->Width() - width) / 2;
77  y_offset = (window->Height() - height) / 2;
78  }
79 }