blob: 4c2f6e546a0ebad1647e8af84b366f7f78a65368 [file] [log] [blame]
twiz@google.com6cf53032012-06-22 18:55:55 +00001/*
2 * Copyright 2012 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#ifndef picture_utils_DEFINED
9#define picture_utils_DEFINED
twiz@google.com6cf53032012-06-22 18:55:55 +000010
borenet@google.come21795e2012-09-14 14:34:28 +000011#include "SkTypes.h"
borenet@google.come21795e2012-09-14 14:34:28 +000012
twiz@google.com6cf53032012-06-22 18:55:55 +000013class SkBitmap;
14class SkFILEStream;
twiz@google.com6cf53032012-06-22 18:55:55 +000015class SkPicture;
borenet@google.come21795e2012-09-14 14:34:28 +000016class SkString;
twiz@google.com6cf53032012-06-22 18:55:55 +000017
18namespace sk_tools {
keyar@chromium.org9299ede2012-08-21 19:05:08 +000019 // since PNG insists on unpremultiplying our alpha, we take no precision
20 // chances and force all pixels to be 100% opaque, otherwise on compare we
21 // may not get a perfect match.
22 //
23 // This expects a bitmap with a config type of 8888 and for the pixels to
24 // not be on the GPU.
25 void force_all_opaque(const SkBitmap& bitmap);
26
twiz@google.com6cf53032012-06-22 18:55:55 +000027 // Creates a posix style filepath by concatenating name onto dir with a
28 // forward slash into path.
keyar@chromium.org1cbd47c2012-07-13 18:22:59 +000029 void make_filepath(SkString* path, const SkString&, const SkString& name);
twiz@google.com6cf53032012-06-22 18:55:55 +000030
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +000031 // Returns the last part of the path (file name or leaf directory name)
32 //
33 // This basically just looks for a foward slash or backslash (windows
keyar@chromium.org9299ede2012-08-21 19:05:08 +000034 // only).
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +000035 void get_basename(SkString* basename, const SkString& path);
36
keyar@chromium.org163b5672012-08-01 17:53:29 +000037 // Returns true if the string ends with %
scroggo@google.com58b4ead2012-08-31 16:15:22 +000038 bool is_percentage(const char* const string);
keyar@chromium.org163b5672012-08-01 17:53:29 +000039
twiz@google.com6cf53032012-06-22 18:55:55 +000040 // Prepares the bitmap so that it can be written.
41 //
42 // Specifically, it configures the bitmap, allocates pixels and then
43 // erases the pixels to transparent black.
44 void setup_bitmap(SkBitmap* bitmap, int width, int height);
twiz@google.com6cf53032012-06-22 18:55:55 +000045}
46
47#endif // picture_utils_DEFINED