aboutsummaryrefslogtreecommitdiff
path: root/turbojpeg.h
diff options
context:
space:
mode:
authordcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2011-03-01 09:53:07 +0000
committerdcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2011-03-01 09:53:07 +0000
commit0d4eb69ae2369e0fbd2d8c5922cf8c376f77edd6 (patch)
tree2a54f010b1810ae9b0c4a3cf315326f18a24b156 /turbojpeg.h
parentd5d50699feafbfa593f59c8c96abb769d4b045a4 (diff)
tjGetScaledSize() would never be able to accommodate scaling factors > 1, so replace it with a function that returns a list of fractional scaling factors that TurboJPEG supports.
git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@477 632fc199-4ca6-4c93-a231-07263d6284db
Diffstat (limited to 'turbojpeg.h')
-rw-r--r--turbojpeg.h46
1 files changed, 22 insertions, 24 deletions
diff --git a/turbojpeg.h b/turbojpeg.h
index a08a434..78ed073 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -56,6 +56,12 @@ enum {TJ_444=0, TJ_422, TJ_420, TJ_GRAYSCALE};
#define TJ_YUV 512
/* Nothing to see here. Pay no attention to the man behind the curtain. */
+/* Scaling factor structure */
+typedef struct
+{
+ int num, denom;
+} tjscalingfactor;
+
/* Transform operations for tjTransform() */
#define NUMXFORMOPT 8
@@ -299,23 +305,16 @@ DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle j,
/*
- int tjGetScaledSize(int input_width, int input_height,
- int *output_width, int *output_height)
-
- [INPUT] input_width = width (in pixels) of the JPEG image
- [INPUT] input_height = height (in pixels) of the JPEG image
- [INPUT/OUTPUT] output_width, output_height = Before calling this function,
- *output_width and *output_height should be set to the desired dimensions
- of the output image. Upon returning from this function, they will be set
- to the dimensions of the largest scaled down image that TurboJPEG can
- produce without exceeding the desired dimensions. If either *output_width
- or *output_height is set to 0, then the corresponding dimension will not
- be considered when determining the scaled image size.
-
- RETURNS: 0 on success, -1 if arguments are out of bounds
+ tjscalingfactor *tjGetScalingFactors(int *numscalingfactors)
+
+ Returns a list of fractional scaling factors that the JPEG decompressor in
+ this implementation of TurboJPEG supports.
+
+ [OUTPUT] numscalingfactors = the size of the list
+
+ RETURNS: NULL on error
*/
-DLLEXPORT int DLLCALL tjGetScaledSize(int input_width, int input_height,
- int *output_width, int *output_height);
+DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors);
/*
@@ -331,10 +330,10 @@ DLLEXPORT int DLLCALL tjGetScaledSize(int input_width, int input_height,
[INPUT] size = size of the JPEG image buffer (in bytes)
[INPUT] dstbuf = pointer to user-allocated image buffer which will receive
the bitmap image. This buffer should normally be pitch*scaled_height
- bytes in size, where scaled_height is determined by calling
- tjGetScaledSize() with the height of the desired output image. This
- pointer may also be used to decompress into a specific region of a
- larger buffer.
+ bytes in size, where scaled_height is ceil(jpeg_height*scaling_factor),
+ and the supported scaling factors can be determined by calling
+ tjGetScalingFactors(). The dstbuf pointer may also be used to decompress
+ into a specific region of a larger buffer.
[INPUT] width = desired width (in pixels) of the destination image. If this
is smaller than the width of the JPEG image being decompressed, then
TurboJPEG will use scaling in the JPEG decompressor to generate the
@@ -345,10 +344,9 @@ DLLEXPORT int DLLCALL tjGetScaledSize(int input_width, int input_height,
scaled_width*pixelsize if the bitmap image is unpadded, else
TJPAD(scaled_width*pixelsize) if each line of the bitmap is padded to the
nearest 32-bit boundary, such as is the case for Windows bitmaps.
- (NOTE: scaled_width can be determined by calling tjGetScaledSize().) You
- can also be clever and use this parameter to skip lines, etc. Setting
- this parameter to 0 is the equivalent of setting it to
- scaled_width*pixelsize.
+ (NOTE: scaled_width = ceil(jpeg_width*scaling_factor).) You can also be
+ clever and use this parameter to skip lines, etc. Setting this parameter
+ to 0 is the equivalent of setting it to scaled_width*pixelsize.
[INPUT] height = desired height (in pixels) of the destination image. If
this is smaller than the height of the JPEG image being decompressed, then
TurboJPEG will use scaling in the JPEG decompressor to generate the