mirror of
https://github.com/nothings/stb
synced 2025-01-06 14:52:00 +03:00
Progress report.
This commit is contained in:
parent
75bdd2da83
commit
fb059fcece
@ -223,6 +223,19 @@ STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int
|
||||
// (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use.
|
||||
|
||||
|
||||
// Define this if you want a progress report.
|
||||
// Example:
|
||||
// void my_progress_report(float progress)
|
||||
// {
|
||||
// printf("Progress: %f%%\n", progress*100);
|
||||
// }
|
||||
//
|
||||
// #define STBIR_PROGRESS_REPORT my_progress_report
|
||||
|
||||
#ifndef STBIR_PROGRESS_REPORT
|
||||
#define STBIR_PROGRESS_REPORT(float_0_to_1)
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//// end header file /////////////////////////////////////////////////////
|
||||
@ -1447,6 +1460,8 @@ static void stbir__buffer_loop_upsample(stbir__info* stbir_info)
|
||||
|
||||
// Now all buffers should be ready to write a row of vertical sampling.
|
||||
stbir__resample_vertical_upsample(stbir_info, y, in_first_scanline, in_last_scanline, in_center_of_out);
|
||||
|
||||
STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1529,6 +1544,8 @@ static void stbir__buffer_loop_downsample(stbir__info* stbir_info)
|
||||
|
||||
// Now the horizontal buffer is ready to write to all ring buffer rows.
|
||||
stbir__resample_vertical_downsample(stbir_info, y, out_first_scanline, out_last_scanline, out_center_of_in);
|
||||
|
||||
STBIR_PROGRESS_REPORT((float)(y + stbir__get_filter_pixel_margin_vertical(stbir_info)) / (max_y + stbir__get_filter_pixel_margin_vertical(stbir_info)));
|
||||
}
|
||||
|
||||
stbir__empty_ring_buffer(stbir_info, stbir_info->output_h);
|
||||
|
@ -46,6 +46,13 @@ void stbir_free(void* context, void* memory)
|
||||
{
|
||||
}
|
||||
|
||||
void stbir_progress(float p)
|
||||
{
|
||||
STBIR_ASSERT(p >= 0 && p <= 1);
|
||||
}
|
||||
|
||||
#define STBIR_PROGRESS_REPORT stbir_progress
|
||||
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#define STB_IMAGE_RESIZE_STATIC
|
||||
#include "stb_image_resize.h"
|
||||
|
Loading…
Reference in New Issue
Block a user