|
|
|
@ -14,6 +14,8 @@ import siprp.database.cayenne.providers.ImageDAO;
|
|
|
|
public final class ImagesServlet extends HttpServlet
|
|
|
|
public final class ImagesServlet extends HttpServlet
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static final long serialVersionUID = 999506147931075031L;
|
|
|
|
private static final long serialVersionUID = 999506147931075031L;
|
|
|
|
|
|
|
|
private static final double MAX_WIDTH = 4.5;
|
|
|
|
|
|
|
|
private static final double MAX_HEIGHT = 2.0;
|
|
|
|
|
|
|
|
|
|
|
|
private static final String PARAMETER_ID = "id";
|
|
|
|
private static final String PARAMETER_ID = "id";
|
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +29,18 @@ public final class ImagesServlet extends HttpServlet
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Integer id = new Integer(param);
|
|
|
|
Integer id = new Integer(param);
|
|
|
|
Image img = new ImageDAO().getImageForID( id );
|
|
|
|
Image img = new ImageDAO().getImageForID( id );
|
|
|
|
|
|
|
|
int width = img.getWidth( null );
|
|
|
|
|
|
|
|
int height = img.getHeight( null );
|
|
|
|
|
|
|
|
double wrel = ((double)width ) / MAX_WIDTH;
|
|
|
|
|
|
|
|
double hrel = ((double)height ) / MAX_HEIGHT;
|
|
|
|
|
|
|
|
if( wrel > 1 && wrel > hrel )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
img = img.getScaledInstance( MAX_WIDTH, -1, Image.SCALE_FAST );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( hrel > 1 && hrel > wrel )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
img = img.getScaledInstance( -1, MAX_HEIGHT, Image.SCALE_FAST );
|
|
|
|
|
|
|
|
}
|
|
|
|
out.write( img.getImageData() );
|
|
|
|
out.write( img.getImageData() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
catch (Exception e) {
|
|
|
|
|