Java jspImage V 3.03
Version française Francais
Main page
Home
[ aDraw | tCalDate | tListe | tEuroCalc | tCalEvent | tChart | tFunction | tOnglet | tCChat | tCount ]
[ aTicker | aFont | aSearch | tBBar | tMButton tButton tScroll | tPassword | Winmine ]
[ Home | Applets | Servlets | ASP components ]

INDEX



News V 3.03
VERSION 3.03
  • Support JPEG format
  • Add Rotation (Graphics2D)
  • Use "javax.imagio" API JDK 1.4 to work without graphics envireonnement (X11)
  • Add line and Rect size
  • Add arrows in lines
  • ...>/li>

VERSION 2.05
  • add BMP formats
  • add encoding parameter.
  • Some changes for aDraw
  • add freehand command
  • ...
Return



Description
jspImage is an JSP component to buil dynamicly an image on the server. This componant support JPEG, GIF and PNG formats.
Return



Registration
jspImage comonent is FreeWare for non commercial sites.
For personal use, please add a link on your site back to my Home Page (http://www.javaside.com/) and send me the URL where you wish to place the jspImage component.
For professional / commercial use, you will need to obtain a "professional registration". With this registration you can use jspImage with no reference to me and I will send you the complete jspImage source code.
If you want to use jspImage in another application, then you must obtain a "professionnal registration".
For more information about "Professional registration" : R. BERTHOU.

Return



JSP Source
<%jsp:useBean id="zz" scope="session" class="javaside.Rbl14.jspImage"/><%
       int iW, iH	    ; // Image size
       String sFormat   ; // Format (gif/png/jpeg)

       String t = null ;
       t = request.getParameter("width") ;
       if (t == null)
           iW = 300 ;
       else
           iW = java.lang.Integer.parseInt(t) ;

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

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


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

       zz.setColor(0xF0F0F0) ;
       zz.fillRect(0, 0, 250, 130) ;

       zz.setColor(0x4040FF) ;
       zz.fillRect(35, 90, 80, 30);

       zz.drawImage(0, 140, 25) ;

       zz.setColor( 0x40FF40 ) ;
       zz.drawOval(165, 105, 80, 30) ;

       zz.setColor(0) ;
       zz.setFont("Serif", 2, 18) ;
       zz.drawString("JavaSide.com...", 25, 82) ;

       zz.setColor( 0x0000FF ) ;
       zz.setFont("Courier", 1, 12 ) ;
       zz.drawString( new java.util.Date().toString(), 5, 152) ;

       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.build() ;
       response.reset();
       response.setContentType("image/" + sFormat );
       response.addHeader("Content-Disposition","filename=jspImage." + sFormat);

       zz.encode( response, sFormat ) ;
       response.flushBuffer();

       zz.clear() ;
%>
Return



Functions
Functions detail
NomDescription
init(int w, int h) action : init image and size definition
newImage() action : init image (clear all)
loadImage(String s, int Id) action : read external image
build() action : build image
setEncoding(String senc) change default encoding
readFile(String f) action : init and read external file to get draw command
readFile(String f, String enc) action : init and read external file to get draw command with new encoding value
readData(String f) action : init and read data in a String to get draw command (for aDraw applet)
addData(String data) read data in a String (for aDraw applet).
getArray(int i) action : get Image in bytes array
saveAs(String s) action : Save image
clear() action : free resources
setColor(int i) action : select color
setColor(int r, int g, int b) action : select color
setFont(String face, int style, int size) action : select font
drawLine(int x, int y, int x2, int y2) action : Draw line
drawLine(int sz, int x, int y, int x2, int y2) draw line with sz size
drawString(String s, int x, int y) action : Draw String
drawString(String s, int x, int y, String enc) action : Draw String with new encoding
drawString(String s, int x, int y, int rot) action : Draw String with a rotation
drawRect(int x, int y, int w, int h) action : Draw rectangle empty
drawRect(int sz, int x, int y, int w, int h) action : Draw rectangle empty with a size "sz"
fillRect(int x, int y, int w, int h) action : Draw rectangle filled
draw3DRect(int x, int y, int w, int h, boolean b) action : Draw 3D rectangle empty
fill3DRect(int x, int y, int w, int h, boolean b) action : Draw 3D rectangle filled
drawRoundRect(int x, int y, int w, int h, int r1, int r2) action : Draw rounded rectangle empty
fillRoundRect(int x, int y, int w, int h, int r1, int r2) action : Draw rectangle bord arrondi filled
drawOval(int x, int y, int w, int h) action : Draw oval empty
drawOval(int sz, int x, int y, int w, int h) action : Draw oval empty with size
fillOval(int x, int y, int w, int h) action : Draw oval filled
drawImage(int iId, int x, int y) action : Draw a loaded image
drawImagePart(int iId, int x, int y, int X, int Y, int W, int H) action : Draw a part of loaded image
fillZone(int x, int y, int color) action : Fill zone (change Color)
drawArc(int x, int y, int w, int h, int r1, int r2) action : Draw arc empty
fillArc(int x, int y, int w, int h, int r1, int r2) action : Draw arc filled
fillZone(int x, int y, int color) action : Fill zone (change Color)
rotate(int ror) action : Make a rotation for next drawing commands.
Return



File Format
With this file you can define some or complete draw commande in external data file.
ColumNameTypeDescription
file.txt (List data file) tChart2
1iIdintcommande Id
  • drawRect = 1
  • draw3DRect = 2
  • drawRoundRect = 3
  • drawOval = 4
  • drawArc = 5
  • fillRect = 6
  • fill3DRect = 7
  • fillRoundRect = 8
  • fillOval = 9
  • fillArc = 10
  • fillZone = 11
  • drawString = 20
  • drawLine = 21
  • drawImage = 22
  • drawImagePart = 23
  • freehand = 24
  • loadImage = 30
  • setFont = 31
  • setColor = 32
  • changeClr = 33
  • rotate = 34
2..nParametersint ou Stringcommand parameters (";" sepparator)
Sample
// setColor Color(0xFFFFFF)
32 ; -1 ;
6  ; 0 ; 0 ; 600 ; 400 ;
// setColor Color(0x0000FF)
32 ; 255 ;
6  ; 100 ; 10 ; 60 ; 100 ;
4  ; 50 ; 100 ; 100 ; 150 ;
32 ; -255 ;
6  ; 10 ; 100 ; 80 ; 150 ;
32 ; 0 ;
20 ; Test Rbl ; 20 ; 50 ;
20 ; Ligne 2  ; 20 ; 150 ;
31 ; Arial ; 0 ; 15 ;
20 ; Arial 15 plain  ; 220 ; 50 ;
32 ; 22554 ;
31 ; Times ; 2 ; 12  ;
20 ; Times 12 italic ;  220 ; 180 ;
22 ; 0 ; 50 ; 120 ; 
Sample jspImage.txt
Return



History
In construction...

1.00Creation...
1.20Add cropImage and fillZone...
2.00 Adaptation for aDraw
3.03 JDK 1.4 support and more

Return



Download files
jspImage V 3.03 jspImage.zip (83 KB)      (backup)
jspImage V 2.05English jspImage_us.zip (81 KB)      (backup)
jspImage V 2.05 Francais jspImage_fr.zip (81 KB)      (backup)
Return




Copyright © 1996..2003, BERTHOU. All right reserved.
Last change : 05 March 2003 18H20