←Select platform

Load(RasterCodecs,Stream,int,CodecsLoadByteOrder) Method

Summary
Loads the specified JPEG 2000 image stream using the specified options.

Syntax
C#
C++/CLI
Python
public: 
RasterImage^ Load(  
   RasterCodecs^ codecs, 
   Stream^ steam, 
   int bitsPerPixel, 
   CodecsLoadByteOrder order 
)  
def Load(self,order): 

Parameters

codecs
The Leadtools.Codecs.RasterCodecs object.

steam
A System.IO.Stream containing the image data to be loaded.

bitsPerPixel
Resulting image pixel depth. If this value is zero [0], the image will have the original file's pixel depth (the image will not be converted).

order
Color order for 16-bit, 24-bit, 32-bit, 48-bit, and 64-bit images. If the resulting image is less than 16 bits per pixel, this will have no effect since palletized images do not use color order. Possible values are:

Value Meaning
CodecsLoadByteOrder.Rgb Red, green, and blue color order in memory
CodecsLoadByteOrder.Bgr Blue, green, and red color order in memory
CodecsLoadByteOrder.Gray 12-bit or 16-bit grayscale image. 12-bit and 16-bit grayscale images are supported only in the Document/Medical Imaging editions.
CodecsLoadByteOrder.RgbOrGray Load the image as red, green, blue OR as a 12-bit or 16-bit grayscale image. 12-bit and 16-bit grayscale images are supported only in the Document/Medical Imaging editions.
CodecsLoadByteOrder.BgrOrGray Load the image as blue, green, red OR as a 12-bit or 16-bit grayscale image. 12-bit and 16-bit grayscale images are supported only in the Document/Medical Imaging editions.
CodecsLoadByteOrder.Romm ROMM order. ROMM only supports 24-bit and 48-bit images.
CodecsLoadByteOrder.BgrOrGrayOrRomm Load the image as red, green, blue OR as a 12-bit or 16-bit grayscale image OR as ROMM. 12-bit and 16-bit grayscale images are supported only in the Document/Medical Imaging editions. ROMM only supports 24-bit and 48-bit color images.

Return Value

The Leadtools.RasterImage object that this method loads.

Remarks

All of the engine boxes will be reset (both those that have been loaded and any that have not been loaded). Only those boxes that have been found in the file during loading are updated.

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:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

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