2 * Copyright 2012 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"
17 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
18 conversion so this tests Skia's internal processing
20 class CMYKJpegGM : public GM {
25 virtual void onOnceBeforeDraw() SK_OVERRIDE {
26 // parameters to the "decode" call
29 SkString jpgFilename = GetResourcePath("CMYK.jpg");
30 SkFILEStream stream(jpgFilename.c_str());
31 if (!stream.isValid()) {
32 SkDebugf("Could not find CMYK.jpg, please set --resourcePath correctly.\n");
36 SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
39 codec->setDitherImage(dither);
40 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
45 virtual SkString onShortName() {
46 return SkString("cmykjpeg");
49 virtual SkISize onISize() {
50 return SkISize::Make(640, 480);
53 virtual void onDraw(SkCanvas* canvas) {
55 canvas->translate(20*SK_Scalar1, 20*SK_Scalar1);
56 canvas->drawBitmap(fBitmap, 0, 0);
65 //////////////////////////////////////////////////////////////////////////////
67 static GM* MyFactory(void*) { return new CMYKJpegGM; }
68 static GMRegistry reg(MyFactory);