Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.WinForms
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Public Sub ToDibExample()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim dib As IntPtr
Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))
dib = image.ToDib(RasterConvertToDibType.BitmapInfoHeader)
End Using
Using image As RasterImage = RasterImage.FromDib(dib)
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_FromDib.bmp"), RasterImageFormat.Bmp, 0)
End Using
Marshal.FreeHGlobal(dib)
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.WinForms;
using Leadtools.Dicom;
using Leadtools.Drawing;
public void ToDibExample()
{
RasterCodecs codecs = new RasterCodecs();
IntPtr dib;
using (RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "Image1.cmp")))
{
dib = image.ToDib(RasterConvertToDibType.BitmapInfoHeader);
}
using(RasterImage image = RasterImage.FromDib(dib))
{
codecs.Save(image, Path.Combine(ImagesPath.Path, "Image1_FromDib.bmp"), RasterImageFormat.Bmp, 0);
}
Marshal.FreeHGlobal(dib);
codecs.Dispose();
}
RasterImageExamples.prototype.ToDibExample = function () {
Tools.SetLicense();
with (Leadtools) {
with (Leadtools.Codecs) {
var codecs = new RasterCodecs();
var dib;
var srcFileName = "Assets\\Image1.cmp";
var image;
var image2;
return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
return codecs.loadAsync(LeadStreamFactory.create(loadFile))
})
.then(function (img) {
image = img;
dib = image.toDib(RasterConvertToDibType.bitmapInfoHeader);
image2 = RasterImage.fromDib(dib, 0);
return Tools.AppLocalFolder().createFileAsync("Image1_FromDib.bmp")
})
.then(function (saveFile) {
var saveStream = LeadStreamFactory.create(saveFile);
return codecs.saveAsync(image, saveStream, RasterImageFormat.bmp, 0)
})
.then(function () {
image2.close();
image.close();
codecs.close();
});
}
}
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
public async Task ToDibExample()
{
RasterCodecs codecs = new RasterCodecs();
Windows.Storage.Streams.IBuffer dib;
string srcFileName = @"Assets\Image1.cmp";
StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
using (RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)))
{
dib = image.ToDib(RasterConvertToDibType.BitmapInfoHeader);
}
using (RasterImage image = RasterImage.FromDib(dib, 0))
{
StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("Image1_FromDib.bmp");
ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
await codecs.SaveAsync(image, saveStream, RasterImageFormat.Bmp, 0);
}
codecs.Dispose();
}