2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "Resources.h"
12 #include "SkImageDecoder.h"
18 * Test copying an image from 8888 to 4444.
20 class CopyTo4444GM : public GM {
25 virtual SkString onShortName() {
26 return SkString("copyTo4444");
29 virtual SkISize onISize() {
30 return SkISize::Make(1024, 512);
33 virtual void onDraw(SkCanvas* canvas) {
35 SkString pngFilename = GetResourcePath("mandrill_512.png");
36 if (!SkImageDecoder::DecodeFile(pngFilename.c_str(), &bm, kN32_SkColorType,
37 SkImageDecoder::kDecodePixels_Mode)) {
38 SkDebugf("Could not decode the file. Did you forget to set the "
42 canvas->drawBitmap(bm, 0, 0);
43 SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType));
44 canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
51 //////////////////////////////////////////////////////////////////////////////
53 static GM* MyFactory(void*) { return new CopyTo4444GM; }
54 static GMRegistry reg(MyFactory);