blob: 7998a23d9643d672515b66a414851813ac092229 [file] [log] [blame]
Leon Scroggins III2e0fadb2018-01-16 21:10:29 -05001/*
2 * Copyright 2018 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -05009#include "include/core/SkCanvas.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkImage.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040011#include "include/core/SkRefCnt.h"
12#include "include/core/SkString.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "tools/Resources.h"
Leon Scroggins III2e0fadb2018-01-16 21:10:29 -050014
15// This gm draws 8 images that are mostly the same when respecting the
16// EXIF orientation tag. Each one has four quadrants (red, blue, green,
17// yellow), and labels on the left, top, right and bottom. The only
18// visual difference is a number in the middle corresponding to the
19// EXIF tag for that image's jpg file.
20DEF_SIMPLE_GM(orientation, canvas, 400, 320) {
21 canvas->save();
22 for (char i = '1'; i <= '8'; i++) {
23 SkString path = SkStringPrintf("images/orientation/%c.jpg", i);
24 auto image = GetResourceAsImage(path.c_str());
Hal Canarybaa2a282018-11-26 15:34:12 -050025 if (!image) {
26 continue;
27 }
Leon Scroggins III2e0fadb2018-01-16 21:10:29 -050028 canvas->drawImage(image, 0, 0);
29 if ('4' == i) {
30 canvas->restore();
31 canvas->translate(0, image->height());
32 } else {
33 canvas->translate(image->width(), 0);
34 }
35 }
36}