Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: gm/copyTo4444.cpp

Issue 22350003: Add downsample from 8888 to 4444. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/copyTo4444.cpp
diff --git a/gm/copyTo4444.cpp b/gm/copyTo4444.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b3dceed639134b5a2aba0623fb7ebc5163e66e04
--- /dev/null
+++ b/gm/copyTo4444.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkImageDecoder.h"
+#include "SkOSFile.h"
+
+namespace skiagm {
+
+/**
+ * Test copying an image from 8888 to 4444.
+ */
+class CopyTo4444GM : public GM {
+public:
+ CopyTo4444GM() {}
+
+protected:
+ virtual SkString onShortName() {
+ return SkString("copyTo4444");
+ }
+
+ virtual SkISize onISize() {
+ return make_isize(1024, 512);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ SkBitmap bm, bm4444;
+ SkString filename = SkOSPath::SkPathJoin(
+ INHERITED::gResourcePath.c_str(), "mandrill_512.png");
+ if (!SkImageDecoder::DecodeFile(filename.c_str(), &bm,
+ SkBitmap::kARGB_8888_Config,
+ SkImageDecoder::kDecodePixels_Mode)) {
+ SkDebugf("Could not decode the file. Did you forget to set the "
+ "resourcePath?\n");
+ return;
+ }
+ canvas->drawBitmap(bm, 0, 0);
+ SkAssertResult(bm.copyTo(&bm4444, SkBitmap::kARGB_4444_Config));
+ canvas->drawBitmap(bm4444, bm.width(), 0);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static GM* MyFactory(void*) { return new CopyTo4444GM; }
+static GMRegistry reg(MyFactory);
+
+}
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698