本文整理匯總了C#中System.Image.IsImgTemplate方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.IsImgTemplate方法的具體用法?C# Image.IsImgTemplate怎麽用?C# Image.IsImgTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Image
的用法示例。
在下文中一共展示了Image.IsImgTemplate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddImage
/**
* Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE>
* is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y)
* The image can be placed inline.
* @param image the <CODE>Image</CODE> object
* @param a an element of the transformation matrix
* @param b an element of the transformation matrix
* @param c an element of the transformation matrix
* @param d an element of the transformation matrix
* @param e an element of the transformation matrix
* @param f an element of the transformation matrix
* @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise
* @param isMCBlockOpened <CODE>true</CODE> not to open MCBlock, <CODE>false</CODE> otherwise
* @throws DocumentException on error
*/
protected internal void AddImage(Image image, double a, double b, double c, double d, double e, double f, bool inlineImage, bool isMCBlockOpened) {
try
{
AffineTransform transform = new AffineTransform(a, b, c, d, e, f);
if (image.Layer != null)
BeginLayer(image.Layer);
if (IsTagged())
{
if (inText)
EndText();
Point2D[] src = new Point2D.Float[]
{new Point2D.Float(0, 0), new Point2D.Float(1, 0), new Point2D.Float(1, 1), new Point2D.Float(0, 1)};
Point2D[] dst = new Point2D.Float[4];
transform.Transform(src, 0, dst, 0, 4);
float left = float.MaxValue;
float right = float.MinValue;
float bottom = float.MaxValue;
float top = float.MinValue;
for (int i = 0; i < 4; i++)
{
if (dst[i].GetX() < left)
left = (float) dst[i].GetX();
if (dst[i].GetX() > right)
right = (float) dst[i].GetX();
if (dst[i].GetY() < bottom)
bottom = (float) dst[i].GetY();
if (dst[i].GetY() > top)
top = (float) dst[i].GetY();
}
image.SetAccessibleAttribute(PdfName.BBOX, new PdfArray(new float[] {left, bottom, right, top}));
}
if (writer != null && image.IsImgTemplate())
{
writer.AddDirectImageSimple(image);
PdfTemplate template = image.TemplateData;
if (image.GetAccessibleAttributes() != null)
{
foreach (PdfName key in image.GetAccessibleAttributes().Keys)
{
template.SetAccessibleAttribute(key, image.GetAccessibleAttribute(key));
}
}
float w = template.Width;
float h = template.Height;
AddTemplate(template, a/w, b/w, c/h, d/h, e, f, isMCBlockOpened);
}
else
{
content.Append("q ");
if (!transform.IsIdentity())
{
content.Append(a).Append(' ');
content.Append(b).Append(' ');
content.Append(c).Append(' ');
content.Append(d).Append(' ');
content.Append(e).Append(' ');
content.Append(f).Append(" cm");
}
if (inlineImage)
{
content.Append("\nBI\n");
PdfImage pimage = new PdfImage(image, "", null);
if (image is ImgJBIG2)
{
byte[] globals = ((ImgJBIG2) image).GlobalBytes;
if (globals != null)
{
PdfDictionary decodeparms = new PdfDictionary();
decodeparms.Put(PdfName.JBIG2GLOBALS, writer.GetReferenceJBIG2Globals(globals));
pimage.Put(PdfName.DECODEPARMS, decodeparms);
}
}
PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_INLINE_IMAGE, pimage);
foreach (PdfName key in pimage.Keys)
{
if (!abrev.ContainsKey(key))
continue;
PdfObject value = pimage.Get(key);
String s = abrev[key];
content.Append(s);
bool check = true;
//.........這裏部分代碼省略.........
示例2: AddImage
/**
* Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE>
* is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y)
* use AddImage(image, image_width, 0, 0, image_height, x, y). The image can be placed inline.
* @param image the <CODE>Image</CODE> object
* @param a an element of the transformation matrix
* @param b an element of the transformation matrix
* @param c an element of the transformation matrix
* @param d an element of the transformation matrix
* @param e an element of the transformation matrix
* @param f an element of the transformation matrix
* @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise
* @throws DocumentException on error
*/
public virtual void AddImage(Image image, float a, float b, float c, float d, float e, float f, bool inlineImage) {
if (image.Layer != null)
BeginLayer(image.Layer);
if (inText && IsTagged()){
EndText();
}
if (writer != null && image.IsImgTemplate()) {
writer.AddDirectImageSimple(image);
PdfTemplate template = image.TemplateData;
float w = template.Width;
float h = template.Height;
AddTemplate(template, a / w, b / w, c / h, d / h, e, f);
}
else {
content.Append("q ");
content.Append(a).Append(' ');
content.Append(b).Append(' ');
content.Append(c).Append(' ');
content.Append(d).Append(' ');
content.Append(e).Append(' ');
content.Append(f).Append(" cm");
if (inlineImage) {
content.Append("\nBI\n");
PdfImage pimage = new PdfImage(image, "", null);
if (image is ImgJBIG2) {
byte[] globals = ((ImgJBIG2)image).GlobalBytes;
if (globals != null) {
PdfDictionary decodeparms = new PdfDictionary();
decodeparms.Put(PdfName.JBIG2GLOBALS, writer.GetReferenceJBIG2Globals(globals));
pimage.Put(PdfName.DECODEPARMS, decodeparms);
}
}
PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_INLINE_IMAGE, pimage);
foreach (PdfName key in pimage.Keys) {
if (!abrev.ContainsKey(key))
continue;
PdfObject value = pimage.Get(key);
String s = abrev[key];
content.Append(s);
bool check = true;
if (key.Equals(PdfName.COLORSPACE) && value.IsArray()) {
PdfArray ar = (PdfArray)value;
if (ar.Size == 4
&& PdfName.INDEXED.Equals(ar.GetAsName(0))
&& ar[1].IsName()
&& ar[2].IsNumber()
&& ar[3].IsString()
) {
check = false;
}
}
if (check && key.Equals(PdfName.COLORSPACE) && !value.IsName()) {
PdfName cs = writer.GetColorspaceName();
PageResources prs = PageResources;
prs.AddColor(cs, writer.AddToBody(value).IndirectReference);
value = cs;
}
value.ToPdf(null, content);
content.Append('\n');
}
content.Append("ID\n");
pimage.WriteContent(content);
content.Append("\nEI\nQ").Append_i(separator);
}
else {
PdfName name;
PageResources prs = PageResources;
Image maskImage = image.ImageMask;
if (maskImage != null) {
name = writer.AddDirectImageSimple(maskImage);
prs.AddXObject(name, writer.GetImageReference(name));
}
name = writer.AddDirectImageSimple(image);
name = prs.AddXObject(name, writer.GetImageReference(name));
content.Append(' ').Append(name.GetBytes()).Append(" Do Q").Append_i(separator);
}
}
if (image.HasBorders()) {
SaveState();
float w = image.Width;
float h = image.Height;
ConcatCTM(a / w, b / w, c / h, d / h, e, f);
Rectangle(image);
RestoreState();
}
//.........這裏部分代碼省略.........
示例3: AddImage
/**
* Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE>
* is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y)
* use AddImage(image, image_width, 0, 0, image_height, x, y). The image can be placed inline.
* @param image the <CODE>Image</CODE> object
* @param a an element of the transformation matrix
* @param b an element of the transformation matrix
* @param c an element of the transformation matrix
* @param d an element of the transformation matrix
* @param e an element of the transformation matrix
* @param f an element of the transformation matrix
* @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise
* @throws DocumentException on error
*/
public virtual void AddImage(Image image, float a, float b, float c, float d, float e, float f, bool inlineImage)
{
if (image.Layer != null)
BeginLayer(image.Layer);
if (image.IsImgTemplate()) {
writer.AddDirectImageSimple(image);
PdfTemplate template = image.TemplateData;
float w = template.Width;
float h = template.Height;
AddTemplate(template, a / w, b / w, c / h, d / h, e, f);
}
else {
content.Append("q ");
content.Append(a).Append(' ');
content.Append(b).Append(' ');
content.Append(c).Append(' ');
content.Append(d).Append(' ');
content.Append(e).Append(' ');
content.Append(f).Append(" cm");
if (inlineImage) {
content.Append("\nBI\n");
PdfImage pimage = new PdfImage(image, "", null);
foreach (PdfName key in pimage.Keys) {
PdfObject value = pimage.Get(key);
String s = (String)abrev[key];
if (s == null)
continue;
content.Append(s);
bool check = true;
if (key.Equals(PdfName.COLORSPACE) && value.IsArray()) {
ArrayList ar = ((PdfArray)value).ArrayList;
if (ar.Count == 4
&& PdfName.INDEXED.Equals(ar[0])
&& ((PdfObject)ar[1]).IsName()
&& ((PdfObject)ar[2]).IsNumber()
&& ((PdfObject)ar[3]).IsString()
) {
check = false;
}
}
if (check && key.Equals(PdfName.COLORSPACE) && !value.IsName()) {
PdfName cs = writer.GetColorspaceName();
PageResources prs = PageResources;
prs.AddColor(cs, writer.AddToBody(value).IndirectReference);
value = cs;
}
value.ToPdf(null, content);
content.Append('\n');
}
content.Append("ID\n");
pimage.WriteContent(content);
content.Append("\nEI\nQ").Append_i(separator);
}
else {
PdfName name;
PageResources prs = PageResources;
Image maskImage = image.ImageMask;
if (maskImage != null) {
name = writer.AddDirectImageSimple(maskImage);
prs.AddXObject(name, writer.GetImageReference(name));
}
name = writer.AddDirectImageSimple(image);
name = prs.AddXObject(name, writer.GetImageReference(name));
content.Append(' ').Append(name.GetBytes()).Append(" Do Q").Append_i(separator);
}
}
if (image.HasBorders()) {
SaveState();
float w = image.Width;
float h = image.Height;
ConcatCTM(a / w, b / w, c / h, d / h, e, f);
Rectangle(image);
RestoreState();
}
if (image.Layer != null)
EndLayer();
Annotation annot = image.Annotation;
if (annot == null)
return;
float[] r = new float[unitRect.Length];
for (int k = 0; k < unitRect.Length; k += 2) {
r[k] = a * unitRect[k] + c * unitRect[k + 1] + e;
r[k + 1] = b * unitRect[k] + d * unitRect[k + 1] + f;
}
float llx = r[0];
//.........這裏部分代碼省略.........