sdlConvertPixels function

bool sdlConvertPixels(
  1. int width,
  2. int height,
  3. int srcFormat,
  4. Pointer<NativeType> src,
  5. int srcPitch,
  6. int dstFormat,
  7. Pointer<NativeType> dst,
  8. int dstPitch,
)

Copy a block of pixels of one format to another format.

\param width the width of the block to copy, in pixels. \param height the height of the block to copy, in pixels. \param src_format an SDL_PixelFormat value of the src pixels format. \param src a pointer to the source pixels. \param src_pitch the pitch of the source pixels, in bytes. \param dst_format an SDL_PixelFormat value of the dst pixels format. \param dst a pointer to be filled in with new pixel data. \param dst_pitch the pitch of the destination pixels, in bytes. \returns true on success or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.1.3.

\sa SDL_ConvertPixelsAndColorspace

extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch)

Implementation

bool sdlConvertPixels(
    int width,
    int height,
    int srcFormat,
    Pointer<NativeType> src,
    int srcPitch,
    int dstFormat,
    Pointer<NativeType> dst,
    int dstPitch) {
  final sdlConvertPixelsLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(
          Int32 width,
          Int32 height,
          Int32 srcFormat,
          Pointer<NativeType> src,
          Int32 srcPitch,
          Int32 dstFormat,
          Pointer<NativeType> dst,
          Int32 dstPitch),
      int Function(
          int width,
          int height,
          int srcFormat,
          Pointer<NativeType> src,
          int srcPitch,
          int dstFormat,
          Pointer<NativeType> dst,
          int dstPitch)>('SDL_ConvertPixels');
  return sdlConvertPixelsLookupFunction(
          width, height, srcFormat, src, srcPitch, dstFormat, dst, dstPitch) ==
      1;
}