I forgot to say, I need to convert from original png8 with transparency to png32 with transparency. Also add a border. By now a problem is in adding a border to a created png32 image with transparency.
using System;
using System.Drawing;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
namespace LeadtoolsApplication
{
class Program
{
static void Main(string[] args)
{
RasterCodecs.Startup();
#region {image loading}
string fileName = @".\Images\PNG_adaptive.png";
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(fileName);
CodecsImageInfo imageInfo = codecs.GetInformation(fileName, false, 1);
#endregion
#region {create png32 with transparency}
image.AddColorToRegion(new RasterColor(Color.White), RasterRegionCombineMode.SetNot);
RasterImage alphaImage = image.CreateMaskFromRegion();
image.SetAlphaImage(alphaImage);
#endregion
#region {add to image a border}
int borderWidth = 30;
RasterColor borderColor = new RasterColor(Color.Green);
#region {create a image base}
RasterImage imageResult = new RasterImage(RasterMemoryFlags.Conventional,
image.Width, image.Height, image.BitsPerPixel, image.Order,
image.ViewPerspective, image.GetPalette(), IntPtr.Zero, 0);
#endregion
#region {fill image base with border color}
FillCommand fillCommand = new FillCommand();
fillCommand.Color = borderColor;
fillCommand.Run(imageResult);
#endregion
#region {cut border of the image}
CropCommand cropCommand = new CropCommand();
cropCommand.Rectangle = new Rectangle(borderWidth, borderWidth,
image.Width - borderWidth * 2, image.Height - borderWidth * 2);
cropCommand.Run(image);
#endregion
#region {combine image base with cut image}
CombineFastCommand combineFastCommand = new CombineFastCommand();
combineFastCommand.DestinationRectangle = new Rectangle(
borderWidth, borderWidth, image.Width, image.Height);
combineFastCommand.SourcePoint = Point.Empty;
combineFastCommand.DestinationImage = imageResult;
combineFastCommand.Flags = CombineFastCommandFlags.SourceCopy;
combineFastCommand.Run(image);
#endregion
#endregion
#region {save the modified image}
string fileNameOut = @".\Images\processed_PNG_adaptive.png";
codecs.Save(imageResult, fileNameOut, RasterImageFormat.Png, 32);
#endregion
RasterCodecs.Shutdown();
}
}
}