2013-08-07 19:16:05 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2014-06-18 21:32:48 +00:00
|
|
|
|
|
|
|
#include "Resources.h"
|
2013-08-07 19:16:05 +00:00
|
|
|
#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() {
|
2014-06-10 06:59:03 +00:00
|
|
|
return SkISize::Make(1024, 512);
|
2013-08-07 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
|
|
SkBitmap bm, bm4444;
|
2014-07-01 19:35:49 +00:00
|
|
|
SkString pngFilename = GetResourcePath("mandrill_512.png");
|
|
|
|
if (!SkImageDecoder::DecodeFile(pngFilename.c_str(), &bm, kN32_SkColorType,
|
2013-08-07 19:16:05 +00:00
|
|
|
SkImageDecoder::kDecodePixels_Mode)) {
|
|
|
|
SkDebugf("Could not decode the file. Did you forget to set the "
|
|
|
|
"resourcePath?\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
canvas->drawBitmap(bm, 0, 0);
|
2014-02-23 03:59:35 +00:00
|
|
|
SkAssertResult(bm.copyTo(&bm4444, kARGB_4444_SkColorType));
|
2013-08-07 19:39:56 +00:00
|
|
|
canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
|
2013-08-07 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef GM INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static GM* MyFactory(void*) { return new CopyTo4444GM; }
|
|
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
|
|
|
|
}
|