Java jspImage V 3.03

INDEX
Image format PNG



Exemple 1 generation image PNG
jspImage sample use for build PNG image.
Retour Index



Source HTML
<img src="jspImage3.jsp?format=png">
Retour Index



Source JSP
<jsp:useBean id="zz" scope="session" class="javaside.Rbl14.jspImage" /><%
       int iW, iH	; // Taille de l image a generer
       String sFormat   ; // Format (gif/png)
       String sBase	= "/mydir/aaa/" ;
       String t = null ;
       
       t = request.getParameter("width") ;
       if (t == null)
	   iW = 380 ;
       else
	   iW = java.lang.Integer.parseInt(t) ;

       t = request.getParameter("height") ;
       if (t == null)
	   iH = 300 ;
       else
	   iH = java.lang.Integer.parseInt(t) ;

       t = request.getParameter("format") ;
       if (t == null)
	   sFormat = "gif" ;
       else
	   sFormat = t ;

	// Initialisation et definition de la taille de l image
        zz.init(iW, iH) ;

        zz.readFile( sBase + "jspImage.txt") ;
	zz.loadImage(sBase + "img/javaside.gif", 0) ;

	zz.setColor(0xFFFF00) ;
	zz.fillArc(20, 35, 170, 170, -50, 50) ;

	zz.setColor(0xF0F040) ;
	zz.fillArc(20, 35, 170, 170, 0, 60) ;

	zz.setColor(0xD0D030) ;
	zz.fillArc(20, 35, 170, 170, 60, 80) ;

	zz.setColor(0xA0A050) ;
	zz.fillArc(20, 35, 170, 170, 140, 60) ;

	zz.setColor( 0x909080 ) ;
	zz.fillArc(20, 35, 170, 170, 200, 50) ;

	zz.setColor(0x4040FF) ;
	zz.fillArc(21, 42, 170, 170, 250, 60) ;

	zz.setColor(0x404020) ;
	zz.drawString( "pas de rotation ", 120, 280, 0) ;
	zz.drawString( "rotation de  45°", 120, 280, 45) ;
	zz.drawString( "rotation de  90°", 120, 280, 90) ;
	zz.drawString( "rotation de 135",  120, 280, 135) ;
	zz.drawString( "rotation de 180°", 120, 280, 180) ;
	zz.drawString( "rotation de -45°", 120, 280, 270 ) ;

	zz.rotate(30) ;
	zz.drawDrawRect(3, 35, 35, 80, 80 ) ;
	zz.drawString( "FIN ... ", 50, 50 ) ;
	zz.rotate(-30) ;

        zz.build() ;

        response.reset();
        response.setContentType("image/" + sFormat );
        response.addHeader("Content-Disposition","filename=image." +  sFormat);

	zz.encode( response, sFormat ) ;

        response.flushBuffer();

	zz.clear() ;
%>
Retour Index



Copyright © 1996..2003, R. BERTHOU. Tous droits réservés.
Dernière modification le 09 March 2003 12H26