Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
How do I transfer the alpha channel from one image to another using 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)
|
Hello, I got two images source an alphaSource and I want to transfer the alphachannel of the alphasource to the source; So far I've gotten so far: Code:using (var alphaReader = ImageReader.Create(@"C:\Users\srombach\AppData\Local\Temp\KittelbergerAMPS3ImagePlugin.alpha.tmpA736.tif"))
using (var sourceReader = new ImageGenerator(alphaReader, RgbColor.Black))
using (var splitter = new ChannelSplitter())
using (var setAlpha = new SetAlpha())
using (var writer = new TiffWriter(Path.GetTempPath() + "alphainjected3.tif"))
{
alphaReader.Receivers.Add(rgbSplitter);
setAlpha.AlphaSource = splitter[Channel.Alpha];
(sourceReader + setAlpha + writer).Run();
}
but it throws an error "No source element in pipemap." which is understandable because the setAlpha.AlphaSource-Pipeline is not executed. I tried various combinations of (https://github.com/aurigma/GraphicsMill.Samples) ChannelsExample.cs, BrightnessContrastExample.cs, MultipleSourcesExample.cs, but came up with no solution. Please set me on the right track. Edited by user Thursday, May 18, 2017 12:58:38 AM(UTC)
| Reason: removed RgbChannelSplitter for ChannelSplitter
|
|
|
|
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)
|
Currently, I see no way to implement it using a single pipeline and without using a temporary file: Code:using (var alphaSourceReader = ImageReader.Create("../../../in.png"))
{
using (var splitter = new RgbChannelSplitter())
using (var alphaWriter = ImageWriter.Create("../../../alpha_temp.tif"))
{
alphaSourceReader.Receivers.Add(splitter);
splitter.A = alphaWriter;
Pipeline.Run(alphaSourceReader);
}
using (var alphaReader = ImageReader.Create("../../../alpha_temp.tif"))
using (var sourceReader = new ImageGenerator(alphaSourceReader, RgbColor.Blue))
using (var setAlpha = new SetAlpha())
using (var sourceWriter = ImageWriter.Create("../../../out.tif"))
{
setAlpha.AlphaSource = alphaReader;
(sourceReader + setAlpha + sourceWriter).Run();
}
}
Even though, we will implement it in the further versions of Graphics Mill (Aurigma Bug #0023326). |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 9/19/2006(UTC) Posts: 505
Was thanked: 41 time(s) in 41 post(s)
|
Hi, Sebastian. You can try to use ChannelCombiner: Code:
using (var sourceReader = ImageReader.Create("source.jpg"))
using (var splitter = new RgbChannelSplitter())
using (var alphaReader = ImageReader.Create("AlphaSource.png"))
using (var alphaSplitter = new RgbChannelSplitter())
using (var writer = ImageWriter.Create("result.png"))
using (var channelCombiner = new RgbChannelCombiner())
{
sourceReader.Receivers.Add(splitter);
alphaReader.Receivers.Add(alphaSplitter);
channelCombiner.R = splitter.R;
channelCombiner.G = splitter.G;
channelCombiner.B = splitter.B;
channelCombiner.A = alphaSplitter.A;
channelCombiner.Receivers.Add(writer);
channelCombiner.RunPipeline();
}
|
Best regards, Eugene Kosmin The Aurigma Development Team
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
How do I transfer the alpha channel from one image to another using 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.