public static Task ExportMapFrameToTGAAsync(string LayoutName, string MFName, string Path) { //Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName)); if (layoutItem == null) { return(Task.FromResult <Layout>(null)); } //Create TGA format with appropriate settings TGAFormat TGA = new TGAFormat(); TGA.Resolution = 300; TGA.OutputFileName = Path; return(QueuedTask.Run(() => { //Export MapFrame Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem MapFrame mf = lyt.FindElement(MFName) as MapFrame; TGA.OutputFileName = Path; if (TGA.ValidateOutputFilePath()) { mf.Export(TGA); } })); }
private void ClearAll() { if (this.bmpTargaImage != null) { this.bmpTargaImage.Dispose(); this.bmpTargaImage = null; } if (this.ImageByteHandle.IsAllocated) { this.ImageByteHandle.Free(); } if (this.ThumbnailByteHandle.IsAllocated) { this.ThumbnailByteHandle.Free(); } this.objTargaHeader = new TargaHeader(); this.objTargaExtensionArea = new TargaExtensionArea(); this.objTargaFooter = new TargaFooter(); this.eTGAFormat = TGAFormat.UNKNOWN; this.intStride = 0; this.intPadding = 0; this.rows.Clear(); this.row.Clear(); this.strFileName = string.Empty; }
private void LoadTGAFooterInfo(BinaryReader binReader) { if (((binReader != null) && (binReader.BaseStream != null)) && ((binReader.BaseStream.Length > 0L) && binReader.BaseStream.CanSeek)) { try { binReader.BaseStream.Seek(-18L, SeekOrigin.End); string strA = Encoding.ASCII.GetString(binReader.ReadBytes(0x10)).TrimEnd(new char[1]); if (string.Compare(strA, "TRUEVISION-XFILE") == 0) { this.eTGAFormat = TGAFormat.NEW_TGA; binReader.BaseStream.Seek(-26L, SeekOrigin.End); int intExtensionAreaOffset = binReader.ReadInt32(); int intDeveloperDirectoryOffset = binReader.ReadInt32(); binReader.ReadBytes(0x10); string strReservedCharacter = Encoding.ASCII.GetString(binReader.ReadBytes(1)).TrimEnd(new char[1]); this.objTargaFooter.SetExtensionAreaOffset(intExtensionAreaOffset); this.objTargaFooter.SetDeveloperDirectoryOffset(intDeveloperDirectoryOffset); this.objTargaFooter.SetSignature(strA); this.objTargaFooter.SetReservedCharacter(strReservedCharacter); return; } this.eTGAFormat = TGAFormat.ORIGINAL_TGA; } catch (Exception exception) { this.ClearAll(); throw exception; } } this.ClearAll(); throw new Exception("Error loading file, could not read file from disk."); }
async public static void ExportSnippets() { LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name")); Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout()); MapFrame mf = lyt.FindElement("Map1 Map Frame") as MapFrame; #region BMP_Constructor BMPFormat BMP = new BMPFormat(); #endregion BMP_Constructor #region EMF_Constructor EMFFormat EMF = new EMFFormat(); #endregion EMF_Constructor #region EPS_Constructor EPSFormat EPS = new EPSFormat(); #endregion EPS_Constructor #region GIF_Constructor GIFFormat GIF = new GIFFormat(); #endregion GIF_Constructor #region JPEG_Constructor JPEGFormat JPEG = new JPEGFormat(); #endregion JPEG_Constructor #region PNG_Constructor PNGFormat PNG = new PNGFormat(); #endregion PNG_Constructor #region PDF_Constructor PDFFormat PDF = new PDFFormat(); #endregion PDF_Constructor #region SVG_Constructor SVGFormat SVG = new SVGFormat(); #endregion SVG_Constructor #region TGA_Constructor TGAFormat TGA = new TGAFormat(); #endregion TGA_Constructor #region TIFF_Constructor TIFFFormat TIFF = new TIFFFormat(); #endregion TIFF_Constructor PDF.OutputFileName = @"C:\Temp\output.pdf"; #region PDF_lyt_Export lyt.Export(PDF); #endregion PDF_lyt_Export }
public static Task ExportActiveMapToTGAAsync(string Path) { return(QueuedTask.Run(() => { //Reference the active map view MapView map = MapView.Active; //Create TGA format with appropriate settings TGAFormat TGA = new TGAFormat(); TGA.Resolution = 300; TGA.Height = 500; TGA.Width = 800; TGA.OutputFileName = Path; //Export active map view if (TGA.ValidateOutputFilePath()) { map.Export(TGA); } })); }
/// <summary> /// Loads the Targa Footer information from the file. /// </summary> /// <param name="binReader">A BinaryReader that points the loaded file byte stream.</param> private void LoadTGAFooterInfo(BinaryReader binReader) { binReader.BaseStream.Seek((TargaConstants.FooterSignatureOffsetFromEnd * -1), SeekOrigin.End); string Signature = System.Text.Encoding.ASCII.GetString(binReader.ReadBytes(TargaConstants.FooterSignatureByteLength)).TrimEnd('\0'); if (string.Compare(Signature, TargaConstants.TargaFooterASCIISignature) == 0) { this.eTGAFormat = TGAFormat.NEW_TGA; binReader.BaseStream.Seek((TargaConstants.FooterByteLength * -1), SeekOrigin.End); int ExtOffset = binReader.ReadInt32(); int DevDirOff = binReader.ReadInt32(); binReader.ReadBytes(TargaConstants.FooterSignatureByteLength); string ResChar = System.Text.Encoding.ASCII.GetString(binReader.ReadBytes(TargaConstants.FooterReservedCharByteLength)).TrimEnd('\0'); this.objTargaFooter.SetExtensionAreaOffset(ExtOffset); this.objTargaFooter.SetDeveloperDirectoryOffset(DevDirOff); this.objTargaFooter.SetSignature(Signature); this.objTargaFooter.SetReservedCharacter(ResChar); } else { this.eTGAFormat = TGAFormat.ORIGINAL_TGA; } }
/// <summary> /// Loads the Targa Footer information from the file. /// </summary> /// <param name="binReader">A BinaryReader that points the loaded file byte stream.</param> private void LoadTGAFooterInfo(BinaryReader binReader) { if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) { try { // set the cursor at the beginning of the signature string. binReader.BaseStream.Seek((TargaConstants.FooterSignatureOffsetFromEnd * -1), SeekOrigin.End); // read the signature bytes and convert to ascii string string Signature = System.Text.Encoding.ASCII.GetString(binReader.ReadBytes(TargaConstants.FooterSignatureByteLength)).TrimEnd('\0'); // do we have a proper signature if (string.Compare(Signature, TargaConstants.TargaFooterASCIISignature) == 0) { // this is a NEW targa file. // create the footer this.eTGAFormat = TGAFormat.NEW_TGA; // set cursor to beginning of footer info binReader.BaseStream.Seek((TargaConstants.FooterByteLength * -1), SeekOrigin.End); // read the Extension Area Offset value int ExtOffset = binReader.ReadInt32(); // read the Developer Directory Offset value int DevDirOff = binReader.ReadInt32(); // skip the signature we have already read it. binReader.ReadBytes(TargaConstants.FooterSignatureByteLength); // read the reserved character string ResChar = System.Text.Encoding.ASCII.GetString(binReader.ReadBytes(TargaConstants.FooterReservedCharByteLength)).TrimEnd('\0'); // set all values to our TargaFooter class this.objTargaFooter.SetExtensionAreaOffset(ExtOffset); this.objTargaFooter.SetDeveloperDirectoryOffset(DevDirOff); this.objTargaFooter.SetSignature(Signature); this.objTargaFooter.SetReservedCharacter(ResChar); } else { // this is not an ORIGINAL targa file. this.eTGAFormat = TGAFormat.ORIGINAL_TGA; } } catch (Exception ex) { // clear all this.ClearAll(); throw ex; } } else { this.ClearAll(); throw new Exception(@"Error loading file, could not read file from disk."); } }
/// <summary> /// Clears out all objects and resources. /// </summary> private void ClearAll() { if (this.bmpTargaImage != null) { this.bmpTargaImage.Dispose(); this.bmpTargaImage = null; } if (this.ImageByteHandle.IsAllocated) this.ImageByteHandle.Free(); if (this.ThumbnailByteHandle.IsAllocated) this.ThumbnailByteHandle.Free(); this.objTargaHeader = new TargaHeader(); this.objTargaExtensionArea = new TargaExtensionArea(); this.objTargaFooter = new TargaFooter(); this.eTGAFormat = TGAFormat.UNKNOWN; this.intStride = 0; this.intPadding = 0; this.rows.Clear(); this.row.Clear(); this.strFileName = string.Empty; }
public void snippets_exportLayout() { #region Export a layout // Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout")); if (layoutItem != null) { QueuedTask.Run(() => { Layout layout = layoutItem.GetLayout(); if (layout == null) { return; } // Create BMP format with appropriate settings BMPFormat BMP = new BMPFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.bmp" }; if (BMP.ValidateOutputFilePath()) { layout.Export(BMP); } // Create EMF format with appropriate settings EMFFormat EMF = new EMFFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.emf" }; if (EMF.ValidateOutputFilePath()) { layout.Export(EMF); } // create eps format with appropriate settings EPSFormat EPS = new EPSFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.eps" }; if (EPS.ValidateOutputFilePath()) { layout.Export(EPS); } // Create GIF format with appropriate settings GIFFormat GIF = new GIFFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.gif" }; if (GIF.ValidateOutputFilePath()) { layout.Export(GIF); } // Create JPEG format with appropriate settings JPEGFormat JPEG = new JPEGFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.jpg" }; if (JPEG.ValidateOutputFilePath()) { layout.Export(JPEG); } // Create PDF format with appropriate settings PDFFormat PDF = new PDFFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.pdf" }; if (PDF.ValidateOutputFilePath()) { layout.Export(PDF); } // Create PNG format with appropriate settings PNGFormat PNG = new PNGFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.png" }; if (PNG.ValidateOutputFilePath()) { layout.Export(PNG); } // Create SVG format with appropriate settings SVGFormat SVG = new SVGFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.svg" }; if (SVG.ValidateOutputFilePath()) { layout.Export(SVG); } // Create TGA format with appropriate settings TGAFormat TGA = new TGAFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.tga" }; if (TGA.ValidateOutputFilePath()) { layout.Export(TGA); } // Create TIFF format with appropriate settings TIFFFormat TIFF = new TIFFFormat() { Resolution = 300, OutputFileName = @"C:\temp\Layout.tif" }; if (TIFF.ValidateOutputFilePath()) { layout.Export(TIFF); } }); } #endregion }
/// <summary> /// Clears out all objects and resources. /// </summary> private void ClearAll() { this.objTargaHeader = new TargaHeader(); this.objTargaExtensionArea = new TargaExtensionArea(); this.objTargaFooter = new TargaFooter(); this.eTGAFormat = TGAFormat.UNKNOWN; this.intStride = 0; this.intPadding = 0; this.rows.Clear(); this.row.Clear(); this.strFileName = string.Empty; }