summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/ImgView.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-01 21:23:39 +0200
committerAki <please@ignore.pl>2022-04-01 21:23:39 +0200
commit3c487c5cd69c53d6fea948643c0a76df03516605 (patch)
tree72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /StarsEx/ImgView.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'StarsEx/ImgView.cpp')
-rw-r--r--StarsEx/ImgView.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/StarsEx/ImgView.cpp b/StarsEx/ImgView.cpp
new file mode 100644
index 0000000..e2c8bba
--- /dev/null
+++ b/StarsEx/ImgView.cpp
@@ -0,0 +1,77 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+
+ AUTHOR: John DiCamillo
+
+
+ OVERVIEW
+ ========
+ Bitmap "billboard" Image View class
+*/
+
+#include "ImgView.h"
+#include "Color.h"
+#include "Window.h"
+#include "Video.h"
+#include "Bitmap.h"
+#include "Screen.h"
+
+// +--------------------------------------------------------------------+
+
+ImgView::ImgView(Window* c, Bitmap* bmp)
+: View(c), img(bmp), width(0), height(0), x_offset(0), y_offset(0),
+blend(Video::BLEND_SOLID)
+{
+ if (img) {
+ width = img->Width();
+ height = img->Height();
+ }
+
+ if (width < c->Width())
+ x_offset = (c->Width() - width) / 2;
+
+ if (height < c->Height())
+ y_offset = (c->Height() - height) / 2;
+}
+
+ImgView::~ImgView()
+{
+}
+
+// +--------------------------------------------------------------------+
+
+void
+ImgView::Refresh()
+{
+ if (img && width > 0 && height > 0)
+ window->DrawBitmap(x_offset,
+ y_offset,
+ x_offset + width,
+ y_offset + height,
+ img,
+ blend);
+}
+
+// +--------------------------------------------------------------------+
+
+void
+ImgView::SetPicture(Bitmap* bmp)
+{
+ img = bmp;
+ width = 0;
+ height = 0;
+ x_offset = 0;
+ y_offset = 0;
+
+ if (img) {
+ width = img->Width();
+ height = img->Height();
+ }
+
+ if (window) {
+ x_offset = (window->Width() - width) / 2;
+ y_offset = (window->Height() - height) / 2;
+ }
+}