aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2015-11-16 07:00:09 +0100
committerEugene Sandulenko2015-11-16 07:00:09 +0100
commitcfc626d78d23ae80a69d145621942f2cae6371f4 (patch)
tree429c606cfe00aa81db8ca4248b1a2c2d5657520e /graphics
parent54feebacb19fed877b205cf68be0e38acc9e8eff (diff)
downloadscummvm-rg350-cfc626d78d23ae80a69d145621942f2cae6371f4.tar.gz
scummvm-rg350-cfc626d78d23ae80a69d145621942f2cae6371f4.tar.bz2
scummvm-rg350-cfc626d78d23ae80a69d145621942f2cae6371f4.zip
GRAPHICS: Implemented utility function to print PixelFormat
Diffstat (limited to 'graphics')
-rw-r--r--graphics/module.mk1
-rw-r--r--graphics/pixelformat.cpp96
-rw-r--r--graphics/pixelformat.h3
3 files changed, 100 insertions, 0 deletions
diff --git a/graphics/module.mk b/graphics/module.mk
index 2705322c79..b6919cf1ab 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS := \
fonts/ttf.o \
fonts/winfont.o \
maccursor.o \
+ pixelformat.o \
primitives.o \
scaler.o \
scaler/thumbnail_intern.o \
diff --git a/graphics/pixelformat.cpp b/graphics/pixelformat.cpp
new file mode 100644
index 0000000000..e7b5401ed6
--- /dev/null
+++ b/graphics/pixelformat.cpp
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "graphics/pixelformat.h"
+#include "common/debug.h"
+
+namespace Graphics {
+
+Common::String PixelFormat::toString() {
+ if (bytesPerPixel == 1)
+ return "CLUT8";
+
+ int component[4];
+ char tmp[10];
+ tmp[0] = tmp[1] = 0;
+
+ component[0] = rShift;
+ component[1] = gShift;
+ component[2] = bShift;
+ component[3] = aShift;
+
+ Common::String letters, digits;
+
+ for (int c = 0; c < 4; c++) {
+ int compPos = -1;
+ int minshift = 100;
+
+ // Find minimal component
+ for (int i = 0; i < 4; i++)
+ if (component[i] >= 0 && component[i] < minshift) {
+ minshift = component[i];
+ compPos = i;
+ }
+
+ // Clean duplicates
+ for (int i = 0; i < 4; i++)
+ if (component[i] == minshift)
+ component[i] = -1;
+
+ switch (compPos) {
+ case 0:
+ if (rLoss != 8) {
+ letters += "R";
+ tmp[0] = '0' + 8 - rLoss;
+ digits += tmp;
+ }
+ break;
+ case 1:
+ if (gLoss != 8) {
+ letters += "G";
+ tmp[0] = '0' + 8 - gLoss;
+ digits += tmp;
+ }
+ break;
+ case 2:
+ if (bLoss != 8) {
+ letters += "B";
+ tmp[0] = '0' + 8 - bLoss;
+ digits += tmp;
+ }
+ break;
+ case 3:
+ if (aLoss != 8) {
+ letters += "A";
+ tmp[0] = '0' + 8 - aLoss;
+ digits += tmp;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return letters + digits;
+}
+
+} // End of namespace Graphics
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index 00db6702fc..3e6c53b05f 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -24,6 +24,7 @@
#define GRAPHICS_PIXELFORMAT_H
#include "common/scummsys.h"
+#include "common/str.h"
namespace Graphics {
@@ -260,6 +261,8 @@ struct PixelFormat {
// Unsupported
return 0;
}
+
+ Common::String toString();
};
} // End of namespace Graphics