public CodecsRawSaveOptions Save { get; }
@property (nonatomic, strong, readonly) LTCodecsRawSaveOptions *save;
public CodecsRawSaveOptions getSave()
public:
property CodecsRawSaveOptions^ Save {
CodecsRawSaveOptions^ get();
}
Save # get (CodecsRawOptions)
The RAW Data save options.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
using Leadtools.Pdf;
private struct RawData
{
public int Width; // Width of image
public int Height; // Height of image
public int BitsPerPixel; // Bits per pixel of image--if palettized, a gray palette is generated
public RasterViewPerspective ViewPerspective; // View perspective of raw data (TopLeft, BottomLeft, etc)
public RasterByteOrder Order; // Rgb or Bgr
public int XResolution; // Horizontal resolution in DPI
public int YResolution; // Vertical resolution in DPI
public int Offset; // Offset into file where raw data begins
public bool Padding; // true if each line of data is padded to four bytes
public bool ReverseBits; // true if the bits of each byte are reversed
}
private RawData myRawData;
private void codecs_LoadInformation(object sender, CodecsLoadInformationEventArgs e)
{
// Set the information
e.Format = RasterImageFormat.Raw;
e.Width = myRawData.Width;
e.Height = myRawData.Height;
e.BitsPerPixel = myRawData.BitsPerPixel;
e.XResolution = myRawData.XResolution;
e.YResolution = myRawData.YResolution;
e.Offset = myRawData.Offset;
if (myRawData.Padding)
e.Pad4 = true;
e.Order = myRawData.Order;
if (myRawData.ReverseBits)
e.LeastSignificantBitFirst = true;
e.ViewPerspective = myRawData.ViewPerspective;
// If image is palettized create a grayscale palette
if (e.BitsPerPixel <= 8)
{
int colors = 1 << e.BitsPerPixel;
RasterColor[] palette = new RasterColor[colors];
for (int i = 0; i < palette.Length; i++)
{
byte val = (byte)((i * 255) / (colors - 1));
palette[i] = new RasterColor(val, val, val);
}
e.SetPalette(palette);
}
}
public void CodecsRawOptionsExample()
{
RasterCodecs codecs = new RasterCodecs();
// First, load a JPEG or CMP file
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"));
// Save this image as RAW data
// Set RAW options
// CodecsRawOptions & CodecsRawSaveOptions reference
codecs.Options.Raw.Save.Pad4 = true;
codecs.Options.Raw.Save.ReverseBits = true;
codecs.Options.Save.OptimizedPalette = true;
string rawFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.raw");
codecs.Save(image, rawFileName, RasterImageFormat.Raw, 0);
// Save information about this image so we can use it to load the RAW file
myRawData = new RawData();
myRawData.Width = image.Width;
myRawData.Height = image.Height;
myRawData.BitsPerPixel = image.BitsPerPixel;
myRawData.ViewPerspective = image.ViewPerspective;
myRawData.Order = image.Order;
myRawData.XResolution = image.XResolution;
myRawData.YResolution = image.YResolution;
myRawData.Offset = 0;
myRawData.Padding = true;
myRawData.ReverseBits = true;
// We dont need the image anymore
image.Dispose();
// Now load this RAW image back
// First subscribe to the LoadInformation event so we can set the image information
codecs.LoadInformation += new EventHandler<CodecsLoadInformationEventArgs>(codecs_LoadInformation);
// Load the image
image = codecs.Load(rawFileName);
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "raw.bmp"), RasterImageFormat.Bmp, image.BitsPerPixel);
// Unsubscribe from the event
codecs.LoadInformation -= new EventHandler<CodecsLoadInformationEventArgs>(codecs_LoadInformation);
// Clean up
image.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.imageprocessing.core.MinMaxBitsCommand;
private class RawData {
public int Width; // Width of image
public int Height; // Height of image
public int BitsPerPixel; // Bits per pixel of image--if palettized, a gray palette is generated
public RasterViewPerspective ViewPerspective; // View perspective of raw data (TopLeft, BottomLeft, etc)
public RasterByteOrder Order; // Rgb or Bgr
public int XResolution; // Horizontal resolution in DPI
public int YResolution; // Vertical resolution in DPI
public int Offset; // Offset into file where raw data begins
public boolean Padding; // true if each line of data is padded to four bytes
public boolean ReverseBits; // true if the bits of each byte are reversed
}
private RawData myRawData;
CodecsLoadInformationListener infoListener = new CodecsLoadInformationListener() {
@Override
public void onLoadInformation(CodecsLoadInformationEvent e) {
// Set the information
e.setFormat(RasterImageFormat.RAW);
e.setWidth(myRawData.Width);
e.setHeight(myRawData.Height);
e.setBitsPerPixel(myRawData.BitsPerPixel);
e.setXResolution(myRawData.XResolution);
e.setYResolution(myRawData.YResolution);
e.setOffset(myRawData.Offset);
if (myRawData.Padding)
e.setPad4(true);
e.setOrder(myRawData.Order);
if (myRawData.ReverseBits)
e.setLeastSignificantBitFirst(true);
e.setViewPerspective(myRawData.ViewPerspective);
// If image is palettized create a grayscale palette
if (e.getBitsPerPixel() <= 8) {
int colors = 1 << e.getBitsPerPixel();
RasterColor[] palette = new RasterColor[colors];
for (int i = 0; i < palette.length; i++) {
byte val = (byte) ((i * 255) / (colors - 1));
palette[i] = new RasterColor(val, val, val);
}
e.setPalette(palette);
}
}
};
public void codecsRawOptionsExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
RasterCodecs codecs = new RasterCodecs();
// First, load a JPEG or CMP file
RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "barcode1.tif"));
// Save this image as RAW data
// Set RAW options
// CodecsRawOptions & CodecsRawSaveOptions reference
codecs.getOptions().getRaw().getSave().setPad4(true);
codecs.getOptions().getRaw().getSave().setReverseBits(true);
codecs.getOptions().getSave().setOptimizedPalette(true);
String rawFileName = combine(LEAD_VARS_IMAGES_DIR, "Test.raw");
codecs.save(image, rawFileName, RasterImageFormat.RAW, 0);
// Save information about this image so we can use it to load the RAW file
myRawData = new RawData();
myRawData.Width = image.getWidth();
myRawData.Height = image.getHeight();
myRawData.BitsPerPixel = image.getBitsPerPixel();
myRawData.ViewPerspective = image.getViewPerspective();
myRawData.Order = image.getOrder();
myRawData.XResolution = image.getXResolution();
myRawData.YResolution = image.getYResolution();
myRawData.Offset = 0;
myRawData.Padding = true;
myRawData.ReverseBits = true;
// We dont need the image anymore
image.dispose();
// Now load this RAW image back
// First subscribe to the LoadInformation event so we can set the image
// information
codecs.addLoadInformationListener(infoListener);
// Load the image
image = codecs.load(rawFileName);
String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "raw.bmp");
codecs.save(image, outputFileName, RasterImageFormat.BMP, image.getBitsPerPixel());
assertTrue("File unsuccessfully saved to " + outputFileName, (new File(outputFileName)).exists());
System.out.printf("File successfully saved to %s%n", outputFileName);
// Unsubscribe from the event
codecs.removeLoadInformationListener(infoListener);
// Clean up
image.dispose();
codecs.dispose();
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document