Trying to create an image with
Code: Select all
var bitmap = new MagickImage(MagickColor.FromRgba(0, 0, 0, 255), size, size);
Code: Select all
var bitmap = new MagickImage(MagickColor.FromRgba(0, 0, 0, 0), size, size);
As i couldn't find a function to fill the whole image, like drawing a filled rectangle without border which is the size of the image, i ended up creating a black image with alpha 255 like this:
Code: Select all
var bitmap = new MagickImage(MagickColor.FromRgb(0, 0, 0), size, size);
bitmap.Transparent(MagickColor.FromRgb(0, 0, 0));
Anyway, when trying to save the image as 32bit windows bmp, alpha got stripped away and the file saved was 24bit:
Code: Select all
using (var os = new System.IO.FileStream("asdf.bmp", System.IO.FileMode.Create))
{
bitmap.Write(os, MagickFormat.Bmp3);
}
Anyway, luckily, there's a ToBitmap member in MagickImage which seems to preserve all 32bit, so at the moment i ended up using this:
Code: Select all
var bmp = bitmap.ToBitmap(System.Drawing.Imaging.ImageFormat.Bmp);
bmp.Save("asdf.bmp");
Can this be done with Magick.NET? Is the mentioned Bmp4 type already released in a newer Magick.NET package? Is there a flag i can set which mimics the "-define bmp3:alpha=true" mentioned in that link?