Beispiel #1
0
        public static bool write( BufferedImage im, string formatName, File output )
        {
            System.Drawing.Imaging.ImageFormat fmt = System.Drawing.Imaging.ImageFormat.Bmp;
            switch ( formatName ) {
                case "BMP":
                case "bmp":
                fmt = System.Drawing.Imaging.ImageFormat.Bmp;
                break;
                case "jpg":
                case "JPG":
                case "jpeg":
                case "JPEG":
                fmt = System.Drawing.Imaging.ImageFormat.Jpeg;
                break;
                case "png":
                case "PNG":
                fmt = System.Drawing.Imaging.ImageFormat.Png;
                break;
                case "GIF":
                case "gif":
                fmt = System.Drawing.Imaging.ImageFormat.Gif;
                break;
                default:
                return false;
            }
            System.IO.FileStream fs = null;
            bool ret = false;
            try {
#if DEBUG
                sout.println( "ImageIO#write; output.getPath()=" + output.getPath() );
#endif
                fs = new System.IO.FileStream( output.getPath(), System.IO.FileMode.Create, System.IO.FileAccess.Write );
                im.image.Save( fs, fmt );
                ret = true;
            } catch ( System.Exception ex ) {
                ret = false;
                Logger.write( typeof( ImageIO ) + ".write; ex=" + ex );
                sout.println( typeof( ImageIO ) + "#write; ex=" + ex );
            } finally {
                if ( fs != null ) {
                    try {
                        fs.Close();
                    } catch { }
                }
            }
            return ret;
        }
Beispiel #2
0
 private void GenerateAuthorList() {
     const float shadow_shift = 2f;
     const string font_name = "Arial";
     const int font_size = 10;
     Font font = new Font( font_name, java.awt.Font.PLAIN, font_size );
     Dimension size = com.github.cadencii.apputil.Util.measureString( "Qjqp", font );
     float width = this.Width;
     float height = size.height;
     //StringFormat sf = new StringFormat();
     m_scroll = new BufferedImage( (int)width, (int)(40f + m_credit.Length * height * 1.1f), BufferedImage.TYPE_INT_BGR );
     Graphics2D g = m_scroll.createGraphics();
     //sf.Alignment = StringAlignment.Center;
     g.setFont( new Font( font_name, java.awt.Font.BOLD, (int)(font_size * 1.1f) ) );
     if ( m_shadow_enablde ) {
         g.setColor( new Color( 0, 0, 0, 40 ) );
         g.drawString( m_app_name, shadow_shift, shadow_shift ); //, width, height ), sf );
     }
     g.setColor( Color.black );
     g.drawString( m_app_name, 0f, 0f ); //, width, height ), sf );
     for ( int i = 0; i < m_credit.Length; i++ ) {
         g.setFont( new Font( font_name, m_credit[i].getStyle(), font_size ) );
         if ( m_shadow_enablde ) {
             g.setColor( new Color( 0, 0, 0, 40 ) );
             g.drawString( m_credit[i].getName(), 0f + shadow_shift, 40f + i * height * 1.1f + shadow_shift ); //, width, height ), sf );
         }
         g.setColor( Color.black );
         g.drawString( m_credit[i].getName(), 0f, 40f + i * height * 1.1f );// , width, height ), sf );
     }
 }