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

Side by Side Diff: gm/cmykjpeg.cpp

Issue 1791583002: Remove uses of SkImageDecoder from gms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « gm/avoidxfermode.cpp ('k') | gm/copyTo4444.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9
10 #include "Resources.h"
11 #include "SkCanvas.h"
12 #include "SkImageDecoder.h"
13 #include "SkStream.h"
14
15 namespace skiagm {
16
17 /** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
18 conversion so this tests Skia's internal processing
19 */
20 class CMYKJpegGM : public GM {
21 public:
22 CMYKJpegGM() {}
23
24 protected:
25 void onOnceBeforeDraw() override {
26 // parameters to the "decode" call
27 bool dither = false;
28
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 correct ly.\n");
33 return;
34 }
35
36 SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
37 if (codec) {
38 stream.rewind();
39 codec->setDitherImage(dither);
40 codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::k DecodePixels_Mode);
41 delete codec;
42 }
43 }
44
45 virtual SkString onShortName() override {
46 return SkString("cmykjpeg");
47 }
48
49 virtual SkISize onISize() override {
50 return SkISize::Make(640, 480);
51 }
52
53 virtual void onDraw(SkCanvas* canvas) override {
54
55 canvas->translate(20*SK_Scalar1, 20*SK_Scalar1);
56 canvas->drawBitmap(fBitmap, 0, 0);
57 }
58
59 private:
60 SkBitmap fBitmap;
61
62 typedef GM INHERITED;
63 };
64
65 //////////////////////////////////////////////////////////////////////////////
66
67 static GM* MyFactory(void*) { return new CMYKJpegGM; }
68 static GMRegistry reg(MyFactory);
69
70 }
OLDNEW
« no previous file with comments | « gm/avoidxfermode.cpp ('k') | gm/copyTo4444.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698