layout: doc title: “Starboard Module Reference: image.h”

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

Let‘s assume that we’re on a Blitter platform.
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 = SbDecodeImage(provider, data, data_size, mime_type, format); SbBlitterSurface surface = SbDecodeTargetGetPlane(target, kSbDecodeTargetPlaneRGBA); // Do stuff with surface...

Functions

SbImageDecode

Description

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:

Declaration and definitions

#include "starboard/configuration.h"
#include "starboard/image.h"

#if !SB_HAS(GRAPHICS)
#error "SbImageDecode requires SB_HAS(GRAPHICS)."
#endif

SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider,
                             void* data,
                             int data_size,
                             const char* mime_type,
                             SbDecodeTargetFormat format) {
  SB_UNREFERENCED_PARAMETER(data);
  SB_UNREFERENCED_PARAMETER(data_size);
  SB_UNREFERENCED_PARAMETER(format);
  SB_UNREFERENCED_PARAMETER(mime_type);
  SB_UNREFERENCED_PARAMETER(provider);
  return kSbDecodeTargetInvalid;
}

Parameters

SbImageIsDecodeSupported

Description

Whether the current platform supports hardware accelerated decoding an image of mime type mime_type into SbDecodeTargetFormat format. 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 and definitions

#include "starboard/configuration.h"
#include "starboard/image.h"

#if !SB_HAS(GRAPHICS)
#error "Requires SB_HAS(GRAPHICS)."
#endif

bool SbImageIsDecodeSupported(const char* mime_type,
                              SbDecodeTargetFormat format) {
  SB_UNREFERENCED_PARAMETER(mime_type);
  SB_UNREFERENCED_PARAMETER(format);
  return false;
}

Parameters