Leon Scroggins III | 2e0fadb | 2018-01-16 21:10:29 -0500 | [diff] [blame] | 1 | /* |
| 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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 9 | #include "include/core/SkCanvas.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkImage.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 11 | #include "include/core/SkRefCnt.h" |
| 12 | #include "include/core/SkString.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "tools/Resources.h" |
Leon Scroggins III | 2e0fadb | 2018-01-16 21:10:29 -0500 | [diff] [blame] | 14 | |
| 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. |
| 20 | DEF_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 Canary | baa2a28 | 2018-11-26 15:34:12 -0500 | [diff] [blame] | 25 | if (!image) { |
| 26 | continue; |
| 27 | } |
Leon Scroggins III | 2e0fadb | 2018-01-16 21:10:29 -0500 | [diff] [blame] | 28 | 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 | } |