I am attempting to manipluate a bmp and save as a tiff with some modifications like size, dpi, and color/b&w/grayscale.
B&W and grayscale are working fine but when choosing the color, it always saves black and white (bitonal).
Here is the code block. I can confirm that filepath is indeed a color bitmap image file. Thank you.
RasterImage img = (RasterImage)Aspose.Imaging.Image.Load(filepath);
int newWidth = img.Width;
int newHeight = img.Height;
if (newWidth > _tiffParameters.MaxWidth)
newWidth = _tiffParameters.MaxWidth;
if (newHeight > _tiffParameters.MaxHeight)
newHeight = _tiffParameters.MaxHeight;
if(newWidth != img.Width)
img.Resize(_tiffParameters.MaxWidth, _tiffParameters.MaxHeight);
TiffOptions options = new TiffOptions(TiffExpectedFormat.Default);
options.Xresolution = new TiffRational((uint)_tiffParameters.Dpi);
options.Yresolution = new TiffRational((uint)_tiffParameters.Dpi);
options.ResolutionUnit = TiffResolutionUnits.Inch;
if (_tiffParams.ColorScale == ColorScale.BITON)
options.Palette = ColorPaletteHelper.CreateMonochrome();
else if (_tiffParams.ColorScale == ColorScale.GRAYS)
options.Palette = ColorPaletteHelper.Create4BitGrayscale(false);
String newFilePath = filepath.Replace(pathReplace, pathValue);
if(!Directory.Exists(Path.GetDirectoryName(newFilePath)))
Directory.CreateDirectory(Path.GetDirectoryName(newFilePath));
using (TiffImage tiffImage = new TiffImage(new TiffFrame(img)))
{
tiffImage.Save(newFilePath, options);
}