public void Convert(
Stream srcStream,
Stream destStream,
RasterImageFormat format,
int width,
int height,
int bitsPerPixel,
int pageNumber,
CodecsImageInfo info
)
public void convert(ILeadStream srcStream, ILeadStream destStream, RasterImageFormat format, int width, int height, int bitsPerPixel, CodecsImageInfo info)
public:
void Convert(
Stream^ srcStream,
Stream^ destStream,
RasterImageFormat format,
int width,
int height,
int bitsPerPixel,
int pageNumber,
CodecsImageInfo^ info
)
def Convert(self,srcStream,destStream,format,width,height,bitsPerPixel,pageNumber,info):
srcStream
A Stream containing the data of the input image file.
destStream
A Stream that will contain the data of the output image file.
format
The output file format. For valid values, refer to Summary of All Supported File Formats.
width
New width of the output image. If this value is not 0, then the output file will be resized to the width value. Use a value of 0 if you do not wish to resize the output file.
height
New height of the output image. If this value is not 0, then the output file will be resized to the height value. Use a value of 0 if you do not wish to resize the output file.
bitsPerPixel
The output image pixel depth. Note that not all bits per pixel are available to all file formats.
pageNumber
1-based index to the page number to convert.
info
A CodecsImageInfo object specifying more options for the conversion.
If you convert to a lower bits-per-pixel format, this method optimizes the colors automatically. For example, when converting a 24-bit file (16 million colors) to an 8-bit file (256 colors) this method selects the best 256 colors to represent the 24-bit image
Note that this is a high-level method that does conversion from all possible formats to all possible formats.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
public void ConvertExExample()
{
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = false;
string srcPath = Path.Combine(LEAD_VARS.ImagesDir, "image4.gif");
string destPath = Path.Combine(LEAD_VARS.ImagesDir, "JpegPages");
if (!Directory.Exists(destPath))
Directory.CreateDirectory(destPath);
//Find the page count of the file
CodecsImageInfo info = codecs.GetInformation(srcPath, true);
//Loop through all pages
for (int i = 1; i <= info.TotalPages; ++i)
{
//Set the file name for the new image file
string name = Path.GetFileNameWithoutExtension(srcPath);
string destFileName = Path.Combine(destPath, name + "_page" + i + ".jpeg");
// Delete the image if its already there
if (File.Exists(destFileName))
File.Delete(destFileName);
//Convert each page to a new JPEG file
codecs.Convert(srcPath, destFileName, RasterImageFormat.Jpeg, 0, 0, 24, i, info);
}
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
import java.io.*;
import java.net.*;
import java.nio.file.Paths;
import java.util.*;
import java.time.Instant;
import java.time.Duration;
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.codecs.RasterCodecs.FeedCallbackThunk;
import leadtools.drawing.internal.*;
import leadtools.imageprocessing.*;
import leadtools.imageprocessing.color.ChangeIntensityCommand;
import leadtools.svg.*;
public void convertExExample() throws IOException {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
RasterCodecs codecs = new RasterCodecs();
codecs.setThrowExceptionsOnInvalidImages(false);
String srcPath = combine(LEAD_VARS_IMAGES_DIR, "Ocr1-4.tif");
codecs.load(srcPath);
String destPath = combine(LEAD_VARS_IMAGES_DIR, "result.jpg");
File destDir = new File(destPath);
if (!destDir.exists())
destDir.createNewFile();
// Find the page count of the file
CodecsImageInfo info = codecs.getInformation(srcPath, true);
// Loop through all pages
for (int i = 1; i <= info.getTotalPages(); ++i) {
// Set the file name for the new image file
String name = srcPath.substring(LEAD_VARS_IMAGES_DIR.length(), srcPath.indexOf(".tif"));
String destFileName = combine(LEAD_VARS_IMAGES_DIR, name + "_page" + i + ".jpg");
// Delete the image if its already there
File destFile = new File(destFileName);
if (destFile.exists()) {
destFile.delete();
}
// Convert each page to a new JPEG file
codecs.convert(srcPath, destFileName, RasterImageFormat.JPEG, 0, 0, 24, info);
}
// Clean up
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