Starboard Module Reference: image.h
Stay organized with collections
Save and categorize content based on your preferences.
API for hardware accelerated image decoding. This module allows for the client
to feed in raw, encoded data to be decoded directly into an SbDecodeTarget. It
also provides an interface for the client to query what combinations of encoded
image formats and SbDecodeTargetFormats are supported or not.
All functions in this module are safe to call from any thread at any point in
time.
SbImageIsDecodeSupported and SbImageDecode Example
SbDecodeTargetProvider* provider = GetProviderFromSomewhere();
void* data = GetCompressedJPEGFromSomewhere();
int data_size = GetCompressedJPEGSizeFromSomewhere();
const char* mime_type = "image/jpeg";
SbDecodeTargetFormat format = kSbDecodeTargetFormat1PlaneRGBA;
if (!SbImageIsDecodeSupported(mime_type, format)) {
return;
}
SbDecodeTarget result_target = SbImageDecode(provider, data, data_size,
mime_type, format);
Functions
SbImageDecode
Attempt to decode encoded mime_type
image data data
of size data_size
into
an SbDecodeTarget of SbDecodeFormatType format
, possibly using
SbDecodeTargetProvider provider
, if it is non-null. Thus, four following
scenarios regarding the provider may happen:
The provider is required by the SbImageDecode
implementation and no
provider is given. The implementation should gracefully fail by immediately
returning kSbDecodeTargetInvalid.
The provider is required and is passed in. The implementation will proceed
forward, using the SbDecodeTarget from the provider.
The provider is not required and is passed in. The provider will NOT be
called, and the implementation will proceed to decoding however it desires.
The provider is not required and is not passed in. The implementation will
proceed forward. The data
pointer must not be NULL. The mime_type
string
must not be NULL. Thus, it is NOT safe for clients of this API to assume
that the provider
it passes in will be called. Finally, if the decode
succeeds, a new SbDecodeTarget will be allocated. If mime_type
image
decoding for the requested format is not supported or the decode fails,
kSbDecodeTargetInvalid will be returned, with any intermediate allocations
being cleaned up in the implementation.
Declaration
SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider *context_provider, void *data, int data_size, const char *mime_type, SbDecodeTargetFormat format)
SbImageIsDecodeSupported
Whether the current platform supports hardware accelerated decoding an image of
mime type mime_type
into SbDecodeTargetFormat format
. The mime_type
must
not be NULL. The result of this function must not change over the course of the
program, which means that the results of this function may be cached
indefinitely.
Declaration
bool SbImageIsDecodeSupported(const char *mime_type, SbDecodeTargetFormat format)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eProvides an API for hardware-accelerated image decoding, allowing raw encoded data to be decoded into an SbDecodeTarget.\u003c/p\u003e\n"],["\u003cp\u003eOffers an interface to check supported encoded image formats and SbDecodeTargetFormats.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSbImageDecode\u003c/code\u003e function decodes encoded image data into an SbDecodeTarget, using an optional SbDecodeTargetProvider for specific scenarios.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSbImageIsDecodeSupported\u003c/code\u003e function checks if hardware-accelerated decoding is supported for a given mime type and format, with results that can be cached indefinitely.\u003c/p\u003e\n"],["\u003cp\u003eAll functions are thread-safe and can be called at any time.\u003c/p\u003e\n"]]],["This API enables hardware-accelerated image decoding by accepting encoded data and decoding it into an `SbDecodeTarget`. `SbImageIsDecodeSupported` checks if a given `mime_type` and `SbDecodeTargetFormat` combination is supported. `SbImageDecode` attempts the actual decoding, with an optional `SbDecodeTargetProvider`, handling scenarios where a provider is required or not. It returns either a decoded `SbDecodeTarget` or `kSbDecodeTargetInvalid`. Both functions are thread-safe.\n"],null,["API for hardware accelerated image decoding. This module allows for the client\nto feed in raw, encoded data to be decoded directly into an SbDecodeTarget. It\nalso provides an interface for the client to query what combinations of encoded\nimage formats and SbDecodeTargetFormats are supported or not.\n\nAll functions in this module are safe to call from any thread at any point in\ntime.\n\nSbImageIsDecodeSupported and SbImageDecode Example \n\n SbDecodeTargetProvider* provider = GetProviderFromSomewhere();\n void* data = GetCompressedJPEGFromSomewhere();\n int data_size = GetCompressedJPEGSizeFromSomewhere();\n const char* mime_type = \"image/jpeg\";\n SbDecodeTargetFormat format = kSbDecodeTargetFormat1PlaneRGBA;\n\n if (!SbImageIsDecodeSupported(mime_type, format)) {\n return;\n }\n\n SbDecodeTarget result_target = SbImageDecode(provider, data, data_size,\n mime_type, format);\n\nFunctions\n\nSbImageDecode\n\nAttempt to decode encoded `mime_type` image data `data` of size `data_size` into\nan SbDecodeTarget of SbDecodeFormatType `format`, possibly using\nSbDecodeTargetProvider `provider`, if it is non-null. Thus, four following\nscenarios regarding the provider may happen:\n\n1. The provider is required by the `SbImageDecode` implementation and no\n provider is given. The implementation should gracefully fail by immediately\n returning kSbDecodeTargetInvalid.\n\n2. The provider is required and is passed in. The implementation will proceed\n forward, using the SbDecodeTarget from the provider.\n\n3. The provider is not required and is passed in. The provider will NOT be\n called, and the implementation will proceed to decoding however it desires.\n\n4. The provider is not required and is not passed in. The implementation will\n proceed forward. The `data` pointer must not be NULL. The `mime_type` string\n must not be NULL. Thus, it is NOT safe for clients of this API to assume\n that the `provider` it passes in will be called. Finally, if the decode\n succeeds, a new SbDecodeTarget will be allocated. If `mime_type` image\n decoding for the requested format is not supported or the decode fails,\n kSbDecodeTargetInvalid will be returned, with any intermediate allocations\n being cleaned up in the implementation.\n\nDeclaration \n\n SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider *context_provider, void *data, int data_size, const char *mime_type, SbDecodeTargetFormat format)\n\nSbImageIsDecodeSupported\n\nWhether the current platform supports hardware accelerated decoding an image of\nmime type `mime_type` into SbDecodeTargetFormat `format`. The `mime_type` must\nnot be NULL. The result of this function must not change over the course of the\nprogram, which means that the results of this function may be cached\nindefinitely.\n\nDeclaration \n\n bool SbImageIsDecodeSupported(const char *mime_type, SbDecodeTargetFormat format)"]]