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



Go to last post Go to first unread
#1 Posted : Wednesday, May 17, 2017 11:37:33 PM(UTC)

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 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:

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"))
    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

#2 Posted : Friday, May 19, 2017 3:58:53 AM(UTC)

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 64 time(s) in 63 post(s)
Currently, I see no way to implement it using a single pipeline and without using a temporary file:

using (var alphaSourceReader = ImageReader.Create("../../../in.png"))
	using (var splitter = new RgbChannelSplitter())
	using (var alphaWriter = ImageWriter.Create("../../../alpha_temp.tif"))
		splitter.A = alphaWriter;


	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

Eugene Kosmin  
#3 Posted : Monday, May 29, 2017 5:50:18 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 9/19/2006(UTC)
Posts: 457

Was thanked: 28 time(s) in 28 post(s)
Hi, Sebastian.

You can try to use ChannelCombiner:


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())

    channelCombiner.R = splitter.R;
    channelCombiner.G = splitter.G;
    channelCombiner.B = splitter.B;

    channelCombiner.A = alphaSplitter.A;


Best regards,

Eugene Kosmin.

Aurigma Development Team

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.