Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
How do I set the background color during a pipeline?
Rank: Advanced Member
Groups: Guest
Joined: 5/10/2017(UTC) Posts: 33
Thanks: 10 times Was thanked: 1 time(s) in 1 post(s)
|
I'm doing the following, but the backgroundcolor of the resulting bitmap is not Aqua, it's white. Code:var reader = ImageReader.Create(@"input");
var combiner = new Combiner(CombineMode.AlphaOverlay) { TopImage = reader };
var bitmap = new Aurigma.GraphicsMill.Bitmap();
var pipe = new Pipeline
{
new ImageGenerator(new Size(200, 100), reader.PixelFormat, RgbColor.Aqua),
new SetAlpha(0),
combiner,
bitmap
};
pipe.Run();
var bgc = bitmap.ColorManagement.BackgroundColor;
What am I doing wrong?
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
The Bitmap.ColorManagement.BackgroundColor property specifies a background color which is used when a pixel format with alpha channel is converted to a pixel format without alpha channel. So it shouldn't be set to the aqua color which you use in ImageGenerator. BTW, the aqua color has following components: [Red=0, Green=255, Blue=255, Alpha=255] When you apply "SetAlpha(0)" you get: [Red=0, Green=255, Blue=255, Alpha=0] which is totally transparent without any color actually. |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 5/10/2017(UTC) Posts: 33
Thanks: 10 times Was thanked: 1 time(s) in 1 post(s)
|
The pipeline shown above is just the start. Later in the process (and not necessarily within our reach) the resulting image is going to exported to PixelFormat without alpha, where I would expect all transparent areas to become the specified backgroundcolor (Aqua). As it stands, this is not the case. And I cannot load the bitmap of the image, because it is too large.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Originally Posted by: SebastianR Later in the process (and not necessarily within our reach) the resulting image is going to exported to PixelFormat without alpha, where I would expect all transparent areas to become the specified backgroundcolor (Aqua). The ColorConverter should help in this case: Code:using (var reader = ImageReader.Create(@"../../../input.png"))
using (var converter = new ColorConverter(PixelFormat.DiscardAlpha(reader.PixelFormat)))
using (var writer = ImageWriter.Create(@"../../../out.png"))
{
converter.BackgroundColor = RgbColor.Aqua;
(reader + converter + writer).Run();
}
Is it what you need? |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 5/10/2017(UTC) Posts: 33
Thanks: 10 times Was thanked: 1 time(s) in 1 post(s)
|
No. This removes alpha. I don't want to remove alpha at this point, just to set the backgroundcolor, to have it already set for later. I tried this without DiscardAlpha, but the backgroundcolor is not set properly.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Quote:No. This removes alpha. I don't want to remove alpha at this point, just to set the backgroundcolor, to have it already set for later. I tried this without DiscardAlpha, but the backgroundcolor is not set properly. You can store a background color using a separate variable. In any case, this value doesn't affect image processing except when it is used explicitly in either Combiner, ColorConverter or other transforms. Edited by user Tuesday, May 16, 2017 4:42:33 AM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
How do I set the background color during a pipeline?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.