FreeImage_JPEGTransformCombined
DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
Realiza una combinación de de rotación o volteo y recorte sin pérdida en un fichero JPEG. A la entrada, src_file es el fichero JPEG de origen y dst_file el de destino. Es posible usar el mismo fichero de origen y destino: el fichero de origen será transformado y sobrescrito.
El parámetro operation especifica el tipo de transformación a aplicar (ver Tabla 16). Cualquier transformación no reversible puede ser evitada usando el parámetro perfect. El rectángulo de recorte viene definido por los parámetros (left, top, right, bottom) (ver FreeImage_JPEGCrop).
La función trabaja realizando primero la transformación usando el parámetro operation, después se ajusta el rectángulo de recorte, es decir, los parámetros left, top, right y bottom, al tamaño iMCU y a la anchura y altura de destino, y finalmente recortando la imagen transformada.
Se puede usar el valor FIJPEG_OP_NONE para el parámetro operation si no se necesita hacer ninguna transformación, y se puede especificar cero para los parámetros (left, top, right, bottom) si no se necesita una operación de recorte.
Se puede simular el efecto de una operación combinada de trasnformación y recorte usando el valor NULL para el parámetro dst_file.
void testJPEGTransformation() {
BOOL bResult;
// assume source has a width x height = 600x400 and a iMCU size = 16
const char *src_file = "input_test.jpg";
const char *dst_file = "output_test.jpg";
// cropped rectangle
int left, top, right, bottom;
// we require a perfect transformation
BOOL perfect = TRUE;
left = 50; top = 100; right = 650; bottom = 500;
// (optional) simulate the transform and get the new rectangle coordinates
// (adjusted to the iMCU size and to the dst image width & height)
bResult = FreeImage_JPEGTransformCombined(src_file, NULL, FIJPEG_OP_ROTATE_90,
&left, &top, &right, &bottom, perfect);
assert(bResult == TRUE);
// check the cropped rectangle, adjusted for a WxH = 400x600 after rotation
assert( (left == 48) && (right == 400) && (top == 96) && (bottom == 500) );
// then apply the transform
bResult = FreeImage_JPEGTransformCombined(src_file, dst_file, FIJPEG_OP_ROTATE_90,
&left, &top, &right, &bottom, perfect);
assert(bResult == TRUE);
}