34975a4d58
This is a reland of commit 965d9dc948
Upstream changes
- http://cl/434609233
- http://cl/434730162
Original change's description:
> [includes] Remove link between SkImageEncoder and SkBitmap
>
> This cleans up an old TODO and, according to go/chrome-includes
> [1] [2], will save 106 MB (0.05%) of build size.
>
> [1] https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes_2022-03-09_114034.html#view=edges&filter=&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImageEncoder%5C.h%24&included=&limit=1000
> [2] http://screen/ohtAxmQcnXui47q
>
> Change-Id: Ic53bfa827964dd5d2d2dbce12f1722e57ea5a9bc
> Bug: 242216
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518497
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Kevin Lubick <kjlubick@google.com>
Bug: 242216
Change-Id: I5bad2a8764c54e885c5b6cad6070549f2cbeefcf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/520936
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkImageEncoder_DEFINED
|
|
#define SkImageEncoder_DEFINED
|
|
|
|
#include "include/core/SkData.h"
|
|
#include "include/core/SkEncodedImageFormat.h"
|
|
#include "include/core/SkPixmap.h"
|
|
#include "include/core/SkStream.h"
|
|
|
|
class SkBitmap;
|
|
|
|
/**
|
|
* Encode SkPixmap in the given binary image format.
|
|
*
|
|
* @param dst results are written to this stream.
|
|
* @param src source pixels.
|
|
* @param format image format, not all formats are supported.
|
|
* @param quality range from 0-100, this is supported by jpeg and webp.
|
|
* higher values correspond to improved visual quality, but less compression.
|
|
*
|
|
* @return false iff input is bad or format is unsupported.
|
|
*
|
|
* Will always return false if Skia is compiled without image
|
|
* encoders.
|
|
*
|
|
* For SkEncodedImageFormat::kWEBP, if quality is 100, it will use lossless compression. Otherwise
|
|
* it will use lossy.
|
|
*
|
|
* For examples of encoding an image to a file or to a block of memory,
|
|
* see tools/ToolUtils.h.
|
|
*/
|
|
SK_API bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
|
|
SkEncodedImageFormat format, int quality);
|
|
|
|
/**
|
|
* The following helper function wraps SkEncodeImage().
|
|
*/
|
|
SK_API bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFormat f, int q);
|
|
|
|
/**
|
|
* Encode SkPixmap in the given binary image format.
|
|
*
|
|
* @param src source pixels.
|
|
* @param format image format, not all formats are supported.
|
|
* @param quality range from 0-100, this is supported by jpeg and webp.
|
|
* higher values correspond to improved visual quality, but less compression.
|
|
*
|
|
* @return encoded data or nullptr if input is bad or format is unsupported.
|
|
*
|
|
* Will always return nullptr if Skia is compiled without image
|
|
* encoders.
|
|
*
|
|
* For SkEncodedImageFormat::kWEBP, if quality is 100, it will use lossless compression. Otherwise
|
|
* it will use lossy.
|
|
*/
|
|
SK_API sk_sp<SkData> SkEncodePixmap(const SkPixmap& src, SkEncodedImageFormat format, int quality);
|
|
|
|
/**
|
|
* Helper that extracts the pixmap from the bitmap, and then calls SkEncodePixmap()
|
|
*/
|
|
SK_API sk_sp<SkData> SkEncodeBitmap(const SkBitmap& src, SkEncodedImageFormat format, int quality);
|
|
|
|
#endif // SkImageEncoder_DEFINED
|