imgSaveJpg function

bool imgSaveJpg(
  1. Pointer<SdlSurface> surface,
  2. String? file,
  3. int quality
)

Save an SDL_Surface into a JPEG image file.

If the file already exists, it will be overwritten.

\param surface the SDL surface to save. \param file path on the filesystem to write new file to. \param quality 0; 33 is Lowest quality, 34; 66 is Middle quality, 67; 100 is Highest quality. \returns true on success or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL_image 3.0.0.

\sa IMG_SaveJPG_IO

extern SDL_DECLSPEC bool SDLCALL IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality)

Implementation

bool imgSaveJpg(Pointer<SdlSurface> surface, String? file, int quality) {
  final imgSaveJpgLookupFunction = libSdl3Image.lookupFunction<
      Uint8 Function(
          Pointer<SdlSurface> surface, Pointer<Utf8> file, Int32 quality),
      int Function(Pointer<SdlSurface> surface, Pointer<Utf8> file,
          int quality)>('IMG_SaveJPG');
  final filePointer = file != null ? file.toNativeUtf8() : nullptr;
  final result = imgSaveJpgLookupFunction(surface, filePointer, quality) == 1;
  calloc.free(filePointer);
  return result;
}