←Select platform

AppendBox(string,Jpeg2000SingleBox) Method

Summary

Appends a single box to a JPEG 2000 file. This method is available in the Document/Medical Toolkits.

Syntax
C#
C++/CLI
Python
public void AppendBox( 
   string fileName, 
   Jpeg2000SingleBox box 
) 
public: 
void AppendBox(  
   String^ fileName, 
   Jpeg2000SingleBox^ box 
)  
def AppendBox(self,fileName,box): 

Parameters

fileName
System.String containing the name of the JPEG 2000 file.

box
Jpeg2000SingleBox object containing the box data being appended.

Remarks

According to the JPEG 2000 standard a ResolutionBox cannot be appended to a file. Set it using the SetBox method. Attempting to append a ResolutionBox will cause an invalid parameter exception to be thrown.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Jpeg2000; 
 
 
public void SaveStringExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   // Load a JPEG 2000 image 
   Jpeg2000Engine engine = new Jpeg2000Engine(); 
   RasterImage image = engine.Load(codecs, Path.Combine(LEAD_VARS.ImagesDir, "image1.jp2"), 0, CodecsLoadByteOrder.BgrOrGray); 
 
   List<XmlBox> xmlBoxes = engine.GetBoxes<XmlBox>(Jpeg2000FileFormat.LeadJp2); 
   ResolutionBox resBox = (ResolutionBox)engine.GetBox(Jpeg2000FileFormat.LeadJp2, Jpeg2000BoxType.ResolutionBox); 
 
   engine.ResetEngineBoxes(); 
   //Set the JPX engine's XML box 
   engine.SetBoxes(Jpeg2000FileFormat.LeadJpx, xmlBoxes); 
   engine.SetBox(Jpeg2000FileFormat.LeadJpx, resBox); 
   //Save the image in JPX file format 
   engine.Save(codecs, Path.Combine(LEAD_VARS.ImagesDir, "Test.jpx"), image, Jpeg2000FileFormat.LeadJpx, 24, 5); 
   //Append Intellectual Property Rights box 
   String copyRights = ("Copyright (c) 1991-2022 by LEAD Technologies, Inc. All Rights Reserved."); 
   IprBox ipr = new IprBox(); 
   ipr.Data = Encoding.ASCII.GetBytes(copyRights); 
   engine.AppendBox(Path.Combine(LEAD_VARS.ImagesDir, "Test.jpx"), ipr); 
   // Clean up 
   engine.Dispose();          
   image.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Jpeg2000 Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.