Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
SebastianR  
#1 Posted : Monday, May 15, 2017 5:28:42 AM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
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?

Fedor  
#2 Posted : Monday, May 15, 2017 6:44:51 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 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
SebastianR  
#3 Posted : Tuesday, May 16, 2017 12:27:19 AM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
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.
Fedor  
#4 Posted : Tuesday, May 16, 2017 2:22:48 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 post(s)
Originally Posted by: SebastianR Go to Quoted Post
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
SebastianR  
#5 Posted : Tuesday, May 16, 2017 4:07:34 AM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
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.
Fedor  
#6 Posted : Tuesday, May 16, 2017 4:41:18 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 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
Users browsing this topic
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.