Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Created October 10, 2013 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FagnerMartinsBrack/6913939 to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/6913939 to your computer and use it in GitHub Desktop.
public class ResizingAlgorithm {
private ImageDimension image;
public ResizingAlgorithm( int width, int height ) {
this.image = new ImageDimension( width, height );
}
/**
* Redimensiona a largura e o tamanho proporcionavelmente
*/
public ImageDimension resizeTo( int width ) {
double factor = getScaleFactor( width );
int height = ( int )( image.getHeight() * factor );
return new ImageDimension( width, height );
}
private double getScaleFactor( int width ) {
return ( double ) width / image.getWidth();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment