4bf6fd68db
This reverts commit 940c3f136d
.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> add runtime registration for encoders
>
> If we want to make these external dependencies mix-and-match in Google3,
> we'll need to group together the encoders and decoders, everything that
> dependends on each external library.
>
> I was tempted to try to remove these generic encoder entrypoints and
> replace them with calls to the direct equivalents, but I'm not sure
> that's necessary. I think we can just register encoders like decoders.
>
> Change-Id: I41d2d1bb3ceb1daafa62c95d345eb6a70249be75
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213880
> Commit-Queue: Mike Klein <mtklein@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
TBR=mtklein@google.com,scroggo@google.com,brianosman@google.com
Change-Id: I3ee9353ca6b3c6c11feba0503b672d8986a347be
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214107
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
71 lines
2.4 KiB
C
71 lines
2.4 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/SkBitmap.h"
|
|
#include "include/core/SkData.h"
|
|
#include "include/core/SkEncodedImageFormat.h"
|
|
#include "include/core/SkStream.h"
|
|
|
|
/**
|
|
* 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().
|
|
*/
|
|
inline bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFormat f, int q) {
|
|
SkPixmap pixmap;
|
|
return src.peekPixels(&pixmap) && SkEncodeImage(dst, pixmap, f, 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
|