public LeadSize[] GetResolutions()
@property (nonatomic, copy) NSArray<NSValue /*CGSize*/ *> *resolutions;
public LeadSize[] getResolutions()
public:
array<LeadSize>^ GetResolutions();
def GetResolutions(self):
An array of LeadSize structures indicating the resolutions to save.
Currently, this only works with the JBIG format.
For JBIG, the maximum number of resolutions that can be saved is 29.
For a JBIG file, the values of different resolutions are implied because the dimensions of each resolution layer are half the dimensions of the one directly above it.
GetResolutions and SetResolutions are used to determine the highest resolution layer which will be saved in a file. You can fill the array with an actual width and height, or you can fill either the width or height with a valid value, and specify 0 for the other dimension to allow LEADTOOLS to calculate that dimension based on the image's aspect ratio during the next save operation. Note that for JBIG, all the values set in the array are stored, but only the first item is used during an actual file save process.
Ex.
uCount = 3 Resolution[0].Width = 800 Resolution[0].Height = 0
If you then save an image that is 1600 x 1200, the resolutions that are stored in the file would be:
800 x 600 400 x 300 200 x 150
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
using Leadtools.Pdf;
RasterImage image;
private void Codecs_LoadImage(object sender, CodecsLoadImageEventArgs e)
{
//copy each row of data into our manually allocated RasterImage
image.SetRow(e.Row, e.Buffer.Data, image.BytesPerLine * e.Lines);
}
public void AllocateImageExample()
{
string fileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp");
RasterCodecs codecs = new RasterCodecs();
CodecsImageInfo info = codecs.GetInformation(fileName, false);
int size = info.Width * info.Height * info.BitsPerPixel;
IntPtr data = Marshal.AllocHGlobal(size);
image = new RasterImage(RasterMemoryFlags.User, info.Width, info.Height, info.BitsPerPixel, RasterByteOrder.Bgr, info.ViewPerspective, null, data, size);
image.Access();
//Setting the loading options.
//Do NOT allow LEADTOOLS to allocate the image data
codecs.Options.Load.AllocateImage = false; // CodecsOptions & CodecsLoadOptions reference
codecs.Options.Load.StoreDataInImage = false;
//keeping the loaded image data compressed in memory.
codecs.Options.Load.Compressed = true;
codecs.Options.Load.DiskMemory = false;
//force a palletized image to be dithered to the LEAD fixed palette.
codecs.Options.Load.FixedPalette = true;
//we know the format of the file
codecs.Options.Load.Format = RasterImageFormat.Cmp;
//disable loading metadata markers if present in the file, false to ignore them.
codecs.Options.Load.Markers = false;
codecs.Options.Load.NoDiskMemory = true;
codecs.Options.Load.NoInterlace = false;
codecs.Options.Load.NoTiledMemory = true;
codecs.Options.Load.Passes = 0;
//ignore the view perspective stored in the file.
codecs.Options.Load.Rotated = false;
//set negative pixel values to 0.
codecs.Options.Load.Signed = false;
codecs.Options.Load.InitAlpha = true;
//load super-compressed in memory
codecs.Options.Load.SuperCompressed = true;
codecs.Options.Load.TiledMemory = false;
codecs.Options.Load.XResolution = 350;
codecs.Options.Load.YResolution = 350;
//allow loading corrupted images
codecs.Options.Load.LoadCorrupted = true;
codecs.LoadImage += Codecs_LoadImage;
codecs.Load(fileName);
codecs.LoadImage -= Codecs_LoadImage;
image.Release();
//Meta file's comments will be saved.
//CodecsSaveOptions reference
codecs.Options.Save.Comments = true;
codecs.Options.Save.FixedPalette = true;
codecs.Options.Save.GeoKeys = false;
//Tiff file output will be gray.
codecs.Options.Save.GrayOutput = true;
//Meta file's markers will be saved.
codecs.Options.Save.Markers = true;
codecs.Options.Save.MotorolaOrder = false;
codecs.Options.Save.OptimizedPalette = true;
codecs.Options.Save.Password = "LEADTOOLS";
LeadSize[] resolutions = new LeadSize[1];
resolutions[0].Width = 350;
resolutions[0].Height = 350;
codecs.Options.Save.GetResolutions();
codecs.Options.Save.SetResolutions(resolutions);
codecs.Options.Save.Reset();
//Meta file's tags will be saved.
codecs.Options.Save.Tags = true;
codecs.Options.Save.UseImageDitheringMethod = true;
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "allocate_image.tif"), RasterImageFormat.Tif, 8, 1, image.PageCount, 1, CodecsSavePageMode.Overwrite);
// Finalize cannot be called directly, it is invoked automatically.
// To clean up before exiting, use Dispose
image.Dispose();
Marshal.FreeHGlobal(data);
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;
RasterImage image;
public void codecsAllocateImageExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
String fileName = combine(LEAD_VARS_IMAGES_DIR, "barcode1.tif");
RasterCodecs codecs = new RasterCodecs();
CodecsImageInfo info = codecs.getInformation(fileName, false);
byte[] data = new byte[1];
image = new RasterImage(10, info.getWidth(), info.getHeight(), info.getBitsPerPixel(), info.getOrder(),
info.getViewPerspective(), info.getPalette(), data, data.length);
image.access();
// Setting the loading options.
// Do NOT allow LEADTOOLS to allocate the image data
codecs.getOptions().getLoad().setAllocateImage(false);// CodecsOptions & CodecsLoadOptions reference
codecs.getOptions().getLoad().setStoreDataInImage(false);
// keeping the loaded image data compressed in memory.
codecs.getOptions().getLoad().setCompressed(true);
codecs.getOptions().getLoad().setDiskMemory(false);
// force a palletized image to be dithered to the LEAD fixed palette.
codecs.getOptions().getLoad().setFixedPalette(true);
// we know the format of the file
codecs.getOptions().getLoad().setFormat(RasterImageFormat.CMP);
// disable loading metadata markers if present in the file, false to ignore
// them.
codecs.getOptions().getLoad().setMarkers(false);
codecs.getOptions().getLoad().setNoDiskMemory(true);
codecs.getOptions().getLoad().setNoInterlace(false);
codecs.getOptions().getLoad().setNoTiledMemory(true);
codecs.getOptions().getLoad().setPasses(0);
// ignore the view perspective stored in the file.
codecs.getOptions().getLoad().setRotated(false);
// set negative pixel values to 0.
codecs.getOptions().getLoad().setSigned(false);
codecs.getOptions().getLoad().setInitAlpha(true);
// load super-compressed in memory
codecs.getOptions().getLoad().setSuperCompressed(true);
codecs.getOptions().getLoad().setTiledMemory(false);
codecs.getOptions().getLoad().setXResolution(350);
codecs.getOptions().getLoad().setYResolution(350);
// allow loading corrupted images
codecs.getOptions().getLoad().setLoadCorrupted(true);
// Created this method below
codecs.addLoadImageListener(loadListener);
codecs.load(fileName);
codecs.removeLoadImageListener(loadListener);
image.release();
// Meta file's comments will be saved.
// CodecsSaveOptions reference
codecs.getOptions().getSave().setComments(true);
codecs.getOptions().getSave().setFixedPalette(true);
codecs.getOptions().getSave().setGeoKeys(false);
// tiff file output will be gray.
codecs.getOptions().getSave().setGrayOutput(true);
// Meta file's markers will be saved.
codecs.getOptions().getSave().setMarkers(true);
codecs.getOptions().getSave().setMotorolaOrder(false);
codecs.getOptions().getSave().setOptimizedPalette(true);
codecs.getOptions().getSave().setPassword("LEADTOOLS");
LeadSize[] resolutions = new LeadSize[1];
resolutions[0] = new LeadSize();
resolutions[0].setWidth(350);
resolutions[0].setHeight(350);
codecs.getOptions().getSave().getResolutions();
codecs.getOptions().getSave().setResolutions(resolutions);
codecs.getOptions().getSave().reset();
// Meta file's tags will be saved.
codecs.getOptions().getSave().setTags(true);
codecs.getOptions().getSave().setUseImageDitheringMethod(true);
String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "allocate_image.tif");
codecs.save(image, outputFileName, RasterImageFormat.TIF, 8, 1, image.getPageCount(), 1,
CodecsSavePageMode.OVERWRITE);
assertTrue("File unsuccessfully saved to " + outputFileName, (new File(outputFileName)).exists());
System.out.printf("File successfully saved to %s%n", outputFileName);
// Finalize cannot be called directly, it is invoked automatically.
// To clean up before exiting, use Dispose
image.dispose();
data = null;
codecs.dispose();
}
CodecsLoadImageListener loadListener = new CodecsLoadImageListener() {
@Override
public void onLoadImage(CodecsLoadImageEvent e) {
image.setRow(e.getRow(), e.getBuffer().getData(), image.getBytesPerLine() * e.getLines());
}
};
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