diff --git a/nx/include/switch/services/capsdc.h b/nx/include/switch/services/capsdc.h index 3498e9cb..cdf50745 100644 --- a/nx/include/switch/services/capsdc.h +++ b/nx/include/switch/services/capsdc.h @@ -30,3 +30,8 @@ Service* capsdcGetServiceSession(void); * @param[in] out_image_size Output image buffer size, should be at least large enough for RGBA8 width x height. */ Result capsdcDecodeJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_image, size_t out_image_size); + +/** + * @brief Shrinks a jpeg's dimensions by 2. + */ +Result capsdcShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size); diff --git a/nx/source/services/capsdc.c b/nx/source/services/capsdc.c index 7297e58a..6566dc33 100644 --- a/nx/source/services/capsdc.c +++ b/nx/source/services/capsdc.c @@ -39,3 +39,21 @@ Result capsdcDecodeJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption } ); } + +Result capsdcShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size) { + const struct { + u32 width; + u32 height; + CapsScreenShotDecodeOption opts; + } in = { width, height, *opts }; + return serviceDispatchInOut(&g_capsdcSrv, 4001, in, *out_result_size, + .buffer_attrs = { + SfBufferAttr_In | SfBufferAttr_HipcMapAlias, + SfBufferAttr_Out | SfBufferAttr_HipcMapAlias | SfBufferAttr_HipcMapTransferAllowsNonSecure, + }, + .buffers = { + { jpeg, jpeg_size }, + { out_jpeg, out_jpeg_size }, + } + ); +}