여기에 많은 노력을 기울여야 할 때, 여기 나와 있습니다. 그것은 여러 페이지 tif 이미지의 각 페이지에 스탬프를 집어 넣습니다.
public class AccusoftStamper
{
public string Stamp()
{
var fileNameOrStream = ... // Get your image from somewhere
using (var lifetime = AccusoftProvider.ImagXpress) // Replace this with your own license
{
var load = new LoadOptions();
// All my images are multipage tiff files
var save = new SaveOptions { Format = ImageXFormat.Tiff };
save.Tiff.MultiPage = true;
using (ImageX image = ImageX.FromFile(lifetime, fileNameOrStream, load))
{
int offset = 0;
int pages = ImageX.NumPages(lifetime, fileNameOrStream);
for (int i = 0; i < pages; i++)
{
image.Page = i + 1;
save.Tiff.Compression = image.ImageXData.Compression;
var pageStamp = ".." // Get your stamp
StampImage(lifetime, pageStamp, image);
save.Tiff.UseIFDOffset = offset > 0;
save.Tiff.IFDOffset = offset;
image.Save(outputFileName, save);
offset = save.Tiff.IFDOffset;
}
}
}
}
private void StampImage(ImagXpress lifetime, string text, ImageX destination)
{
using (var processor = new Processor(lifetime, destination))
{
int bitsPerPixel = destination.ImageXData.BitsPerPixel;
if (bitsPerPixel != 24) // we can only paint on a 24 bit image.
processor.ColorDepth(24, PaletteType.Optimized, DitherType.NoDither);
using (var g = destination.GetGraphics())
using (var font = new Font(FontFamily.GenericMonospace, 16, FontStyle.Bold))
using (var matrix = new Matrix())
{
try
{
SizeF textSize = g.MeasureString(text, font);
Point location = GetStampLocation(new Size(destination.ImageXData.Width, destination.ImageXData.Height), textSize);
// All my stamping is vertically along the left edge
matrix.Translate(1, 1);
matrix.RotateAt(-90, new PointF(location.X, location.Y));
g.Transform = matrix;
g.DrawString(text,
font,
Brushes.Black,
location.X, location.Y,
new StringFormat());
}
finally
{
destination.ReleaseGraphics();
}
}
// The BPP may change accoding to Accusofts documentation, so change it back to what is was
if (bitsPerPixel != destination.ImageXData.BitsPerPixel)
processor.ColorDepth(bitsPerPixel, PaletteType.Optimized, DitherType.NoDither);
}
}
public Point GetStampLocation(Size imageSize, SizeF textSize)
{
var p = new Point(0, 0);
// Top Right
//p.X += destination.ImageXData.Width;
// Top left
//p.Y += (int)Math.Round(textSize.Width, MidpointRounding.AwayFromZero);
// Need to figure out where you want the stamp to be
return p;
}
}
AccusoftProvider.ImagXpress를 사용하면 무엇입니까? 나는 당신이 당신의 면허를 사용 함으로서 당신이 의미하는 것이 확실하지 않습니다. 이미 작업을 시작했을 때 이미 구현 되었기 때문에 ImagXpress에 익숙하지 않습니다. – Justin
또한 프로그램 사용 중에 언제 발생합니까? 나는 우리의 목표가 페이지에서 우표가 어디로 갈 것인지를 나타내는 그것을 보면서 그들의 이미지 위에 영역을 배치하도록하는 것이라고 믿습니다. – Justin
라이센스를 확인하는 ImagXpress 객체를 인스턴스화하는 데 사용하는 속성입니다. http://help.accusoft.com/ImagXpress/v12.0/dotnet/Accusoft.ImagXpress12.Net~Accusoft.ImagXpressSdk.ImagXpress.html – Frank