- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
package com.photoholding.processimage.eugene;
import java.awt.Point;
import java.awt.Rectangle;
import magick.ImageInfo;
import magick.MagickException;
import magick.MagickImage;
public class ProcessA {
private MagickImage img;
private String text;
private String imageOrigin;
private String fout;
private String fmount;
private final String tmpImg = "tmpIM.jpg";
private final String tmpMnt = "tmpMounted.jpg";
private final int width = 1607;
private final int height = 1205;
public ProcessA( String txt, String fin, String fout, String fmount ){
if( txt.length() > 52 ){
System.out.println( "error: text string more than 52" );
System.exit(0);
}
this.text = txt;
this.img = getImage( fin );
this.imageOrigin = fin;
this.fmount = fmount;
this.fout = fout;
}
private MagickImage getImage( String fin2 ) {
MagickImage im = null;
try {
im = new MagickImage( new ImageInfo( fin2 ) );
} catch ( MagickException e ) {
e.printStackTrace();
return null;
}
return im;
}
public boolean doProcess(){
try {
scaleGenerally();
annotateMounted();
montage();
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
return true;
}
private void montage() throws Exception {
MagickProcessing mp = new MagickProcessing();
mp.montage( tmpMnt, tmpImg, fout );
}
private void annotateMounted() throws Exception {
MagickProcessing mp = new MagickProcessing();
mp.annotateImage( text, new Point( 115, 1195 - ( 598 - ( ( text.length() / 2 ) * 23 ) ) ), fmount, tmpMnt );
}
protected boolean scaleGenerally() throws Exception {
int h = img.getDimension().height;
int w = img.getDimension().width;
MagickProcessing mp = new MagickProcessing();
if( h > w ){
if ( !mp.rotateANDscale( "1607x", imageOrigin, tmpImg )) return false;
img = getImage( tmpImg );
h = img.getDimension().height;
w = img.getDimension().width;
if( h < height ){
if( !mp.rotateANDscale( "x1205", imageOrigin, tmpImg )) return false;
img = getImage( tmpImg );
h = img.getDimension().height;
w = img.getDimension().width;
}
if( !mp.crop( new Rectangle( ( w - width ) / 2, 0, 1607, 1205 ), tmpImg, tmpImg )) return false;
} else {
if( !mp.scaleImage( "1607x", imageOrigin, tmpImg ) ) return false;
img = getImage( tmpImg );
h = img.getDimension().height;
w = img.getDimension().width;
if( h < height ){
if( !mp.scaleImage( "x1205", imageOrigin, tmpImg ) ) return false;
if( !mp.crop( new Rectangle( ( w - width ) / 2, 0, 1607, 1205 ), tmpImg, tmpImg ) ) return false;
} else if( h > height ){
if( !mp.crop( new Rectangle( 0, (int)( h - height ) / 2, width, height ), tmpImg, tmpImg )) return false;
}
}
return true;
}
}
guest 04.03.2009 14:07 # 0
и че? может в следующий раз скинешь линку где можно скачать твой говнопроект?
guest 04.03.2009 14:47 # 0
и? за что бить?