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

Side by Side Diff: gm/image.cpp

Issue 1199473002: change old picture serialization to really handle images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkSurface.h" 13 #include "SkSurface.h"
14 14
15 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
16 #include "GrContext.h" 16 #include "GrContext.h"
17 #endif 17 #endif
18 18
19 static void drawJpeg(SkCanvas* canvas, const SkISize& size) { 19 static void drawJpeg(SkCanvas* canvas, const SkISize& size) {
20 // TODO: Make this draw a file that is checked in, so it can 20 // TODO: Make this draw a file that is checked in, so it can
21 // be exercised on machines other than mike's. Will require a 21 // be exercised on machines other than mike's. Will require a
22 // rebaseline. 22 // rebaseline.
23 SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.goo gle.jpeg")); 23 SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.goo gle.jpeg"));
24 if (NULL == data.get()) { 24 if (NULL == data.get()) {
25 return; 25 return;
26 } 26 }
27 SkImage* image = SkImage::NewFromData(data); 27 SkImage* image = SkImage::NewFromEncoded(data);
28 if (image) { 28 if (image) {
29 SkAutoCanvasRestore acr(canvas, true); 29 SkAutoCanvasRestore acr(canvas, true);
30 canvas->scale(size.width() * 1.0f / image->width(), 30 canvas->scale(size.width() * 1.0f / image->width(),
31 size.height() * 1.0f / image->height()); 31 size.height() * 1.0f / image->height());
32 canvas->drawImage(image, 0, 0, NULL); 32 canvas->drawImage(image, 0, 0, NULL);
33 image->unref(); 33 image->unref();
34 } 34 }
35 } 35 }
36 36
37 static void drawContents(SkSurface* surface, SkColor fillC) { 37 static void drawContents(SkSurface* surface, SkColor fillC) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 canvas->translate(0, image->height() + 20.0f); 279 canvas->translate(0, image->height() + 20.0f);
280 } 280 }
281 } 281 }
282 282
283 private: 283 private:
284 typedef skiagm::GM INHERITED; 284 typedef skiagm::GM INHERITED;
285 }; 285 };
286 DEF_GM( return new ImageResizeGM; ) 286 DEF_GM( return new ImageResizeGM; )
287 287
OLDNEW
« gm/factory.cpp ('K') | « gm/factory.cpp ('k') | include/c/sk_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698