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

Side by Side Diff: gm/encode.cpp

Issue 2245453002: Fix WIC encoder to support kJPEG_Type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Bug fix Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/images/SkForceLinking.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 2011 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 #include "gm.h"
8 #include "SkCanvas.h"
9 #include "SkData.h"
10 #include "SkImageEncoder.h"
11 #include "Resources.h"
12
13 namespace skiagm {
14
15 class EncodeGM : public GM {
16 public:
17 EncodeGM() {}
18
19 protected:
20 SkString onShortName() override {
21 return SkString("encode");
22 }
23
24 SkISize onISize() override {
25 return SkISize::Make(1024, 600);
26 }
27
28 void onDraw(SkCanvas* canvas) override {
29 SkBitmap orig;
30 GetResourceAsBitmap("mandrill_512_q075.jpg", &orig);
31 sk_sp<SkData> pngData(SkImageEncoder::EncodeData(orig, SkImageEncoder::k PNG_Type, 100));
32 sk_sp<SkData> jpegData(SkImageEncoder::EncodeData(orig, SkImageEncoder:: kJPEG_Type, 100));
33
34 sk_sp<SkImage> pngImage = SkImage::MakeFromEncoded(pngData);
35 sk_sp<SkImage> jpegImage = SkImage::MakeFromEncoded(jpegData);
36 canvas->drawImage(pngImage.get(), 0.0f, 0.0f);
37 canvas->drawImage(jpegImage.get(), 512.0f, 0.0f);
38
39 const char text[] = "Images should look identical.";
40 canvas->drawText(text, sizeof(text) - 1, 450.0f, 550.0f, SkPaint());
41 }
42
43 private:
44 typedef GM INHERITED;
45 };
46
47 DEF_GM( return new EncodeGM; )
48 }
OLDNEW
« no previous file with comments | « no previous file | src/images/SkForceLinking.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698