/** * Finds an axis-aligned bounding box which would contain a image after it has been transformed. * A sanity check is done to made sure it is contained inside the destination image's bounds. * If it is totally outside then a rectangle with negative width or height is returned. * * @param srcWidth Width of the source image * @param srcHeight Height of the source image * @param dstWidth Width of the destination image * @param dstHeight Height of the destination image * @param transform Transform being applied to the image * @return Bounding box */ public static RectangleLength2D_I32 boundBox( int srcWidth , int srcHeight , int dstWidth , int dstHeight , PixelTransform2_F32 transform ) { RectangleLength2D_I32 ret = boundBox(srcWidth,srcHeight,transform); int x0 = ret.x0; int y0 = ret.y0; int x1 = ret.x0 + ret.width; int y1 = ret.y0 + ret.height; if( x0 < 0 ) x0 = 0; if( x1 > dstWidth) x1 = dstWidth; if( y0 < 0 ) y0 = 0; if( y1 > dstHeight) y1 = dstHeight; return new RectangleLength2D_I32(x0,y0,x1-x0,y1-y0); }