public class ImageServerConversionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static AspectRatio |
calculateAspectRatio(DimensionsDto dimensions) |
static AspectRatio |
calculateAspectRatio(ImageResolutionDto resolutionDto) |
static int |
calculateDistance(@NonNull DimensionsDto from,
@NonNull DimensionsDto to)
Calculates the distance between two dimensions.
|
static int |
calculateDistance(ImageResolutionDto from,
ImageResolutionDto to) |
static CropDto |
extendCrop(CropDto original,
AspectRatio aspectRatio)
This will extend an existing crop to match a given aspect ratio.
|
static boolean |
fitsIn(DimensionsDto original,
DimensionsDto boundaries)
Checks if the area represented by dimensions fits inside the area defined by the box (the original
area should be the same surface or smaller).
|
static boolean |
isWithinBox(CropDto crop,
DimensionsDto box)
Checks if a crop is entirely positioned within a box.
|
static CropDto |
moveToFit(CropDto original,
DimensionsDto box)
Will shift a crop to fit entirely inside the box.
|
static CropDto |
normalize(CropDto original,
DimensionsDto box)
Will translate a crop to fit inside the box specified.
|
static DimensionsDto |
normalize(DimensionsDto original,
AspectRatio aspectRatio)
Will verify and modify the dimensions so that they match the aspect ratio.
|
static DimensionsDto |
normalize(DimensionsDto original,
DimensionsDto boundaries)
Will calculate the unknown dimensions for the original according to the boundaries specified.
|
static DimensionsDto |
scaleToFitIn(DimensionsDto original,
DimensionsDto box)
Will downscale the dimensions to fit in the boundaries if they are larger.
|
static CropDto |
shrinkCrop(CropDto original,
AspectRatio aspectRatio)
This will shrink an existing crop to match a given aspect ratio.
|
public static AspectRatio calculateAspectRatio(ImageResolutionDto resolutionDto)
public static AspectRatio calculateAspectRatio(DimensionsDto dimensions)
public static CropDto extendCrop(CropDto original, AspectRatio aspectRatio)
moveToFit(CropDto, DimensionsDto) if you also want the crop to be moved about to fit it
in the visible coordinates box.
Crop parameters like source and box will be kept.original - crop coordinatesaspectRatio - the crop should matchmoveToFit(CropDto, DimensionsDto)public static CropDto shrinkCrop(CropDto original, AspectRatio aspectRatio)
original - crop coordinatesaspectRatio - the crop should matchpublic static CropDto moveToFit(CropDto original, DimensionsDto box)
extendCrop(CropDto, AspectRatio)
to verify that the resulting extension does not surpass the box boundaries. This counters the center point
based extending of a crop.
This function will throw an exception if it is not possible to fit the crop inside the box.original - crop coordinatesbox - the crop should fit inIllegalArgumentException - if the crop dimensions are impossible to fit in the boxpublic static DimensionsDto normalize(DimensionsDto original, DimensionsDto boundaries)
original - dimensionsboundaries - for the new dimensionspublic static DimensionsDto normalize(DimensionsDto original, AspectRatio aspectRatio)
original - dimensionsaspectRatio - to use when normalizing the dimensionspublic static CropDto normalize(CropDto original, DimensionsDto box)
original - cropbox - to use for translating the crop coordinatespublic static DimensionsDto scaleToFitIn(DimensionsDto original, DimensionsDto box)
original - dimensionsbox - that the translated dimensions should fit inpublic static boolean fitsIn(DimensionsDto original, DimensionsDto boundaries)
original - dimensions to checkboundaries - that the dimensions should fit inpublic static boolean isWithinBox(CropDto crop, DimensionsDto box)
crop - to checkbox - that should contain the croppublic static int calculateDistance(ImageResolutionDto from, ImageResolutionDto to)
public static int calculateDistance(@NonNull
@NonNull DimensionsDto from,
@NonNull
@NonNull DimensionsDto to)
from - dimensionto - dimensionCopyright © 2020. All rights reserved.