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 | |
| 8 | #include "gm.h" |
| 9 | |
| 10 | #include "SkCanvas.h" |
| 11 | #include "SkColor.h" |
| 12 | #include "SkImage.h" |
| 13 | #include "Resources.h" |
| 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()); |
| 25 | canvas->drawImage(image, 0, 0); |
| 26 | if ('4' == i) { |
| 27 | canvas->restore(); |
| 28 | canvas->translate(0, image->height()); |
| 29 | } else { |
| 30 | canvas->translate(image->width(), 0); |
| 31 | } |
| 32 | } |
| 33 | } |