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         if (!image) {
26             continue;
27         }
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 }
37