←Select platform

FragmentJpxFile Method

Summary
Fragments the specified code streams within a JPEG 2000 part 2 (JPX) file. This method is available in the Document/Medical Toolkits.

Syntax
C#
C++/CLI
Python
public void FragmentJpxFile( 
   string inputFileName, 
   string outputFileName, 
   List<UuidUrl> urls, 
   List<Fragment> fragments 
) 
public: 
void FragmentJpxFile(  
   String^ inputFileName, 
   String^ outputFileName, 
   List<UuidUrl>^ urls, 
   List<Fragment>^ fragments 
)  
def FragmentJpxFile(self,inputFileName,outputFileName,urls,fragments): 

Parameters

inputFileName
System.String containing the name of the JPX file from which frames are to be extracted.

outputFileName
System.String containing the name of the fragmented JPX file.

urls
List of UuidUrl specifying the URLs where the fragments are contained.

fragments
List of Fragment specifying the following for each fragment:

  • The code stream index to be fragmented
  • The index for the URL which contains the fragment
  • The offset of the first byte of the fragment within the specified URL
Remarks

It is up to the user to save the fragmented code streams in their URL locations.

Fragmentation in JPX works by specifying a table of pointers to the individual fragments. Each pointer specifies three things:

  1. The file which contains the fragment. Because multiple fragments across multiple code streams can be stored in the same file, the format encapsulates all filename/URL data into a table (the Data Reference box). Each fragment specification then references an entry in the data reference table.
  2. The offset of the first byte of the fragment within the specified file. This offset is with respect to the first byte of the file (byte 0) and points directly to the first byte of code stream data for the fragment-- it does NOT point to the start of the box containing that fragment.
  3. The length of the fragment, in bytes.

Fragmentation is an important feature of the JPX file format since it allows applications to implement such features as:

  • The capability to edit an image, resaving the changed tiles to the end of the file.
  • The capability to distribute the image across several disks for faster access.
  • The capability to distribute the image across the internet, allowing only certain customers access to the high quality or high resolution portions of the code stream.
  • The capability to reuse the headers from within a code stream across multiple code streams (to minimize file overhead when storing similar code streams within the same JPX file).
Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Jpeg2000; 
 
 
public void FragmentJpxFileExample() 
{ 
   Jpeg2000Engine engine = new Jpeg2000Engine(); 
 
   Jpeg2000FileInformation fileInfo = engine.GetFileInformation(Path.Combine(LEAD_VARS.ImagesDir, "image1.jpx")); 
 
   if (1 > fileInfo.CodeStream.GetLength(0)) 
      return; 
 
   List<int> frames = new List<int>(); 
   frames.Add(0); 
   UuidUrl url = new UuidUrl(); 
   url.Flag = new byte[3]; 
   url.Flag[0] = 0; 
   url.Flag[1] = 0; 
   url.Flag[2] = 0; 
   url.Version = 0; 
   String loaction = Path.Combine(LEAD_VARS.ImagesDir, "codestream.bin"); 
   byte[] data = Encoding.ASCII.GetBytes(loaction); 
   url.Location = new byte[data.GetLength(0)]; 
   data.CopyTo(url.Location, 0); 
 
   List<UuidUrl> urls = new List<UuidUrl>(); 
   urls.Add(url); 
   Fragment fragment = new Fragment(); 
   fragment.CodeStreamIndex = 0; 
   fragment.Offset = 0; 
   fragment.UrlIndex = 0; 
   List<Fragment> fragments = new List<Fragment>(); 
   fragments.Add(fragment); 
   engine.FragmentJpxFile(Path.Combine(LEAD_VARS.ImagesDir, "image1.jpx"), Path.Combine(LEAD_VARS.ImagesDir, "Test.jpx"), urls, fragments); 
} 
 
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.