Unfortunately, I have not found a way to do this yet.
Does a method like Graphics.DrawImage() exist in ImageProcessorCore?
E.g. it would be great if something like this would work:
using (Graphics g = Graphics.FromImage(_resultImage))
{
g.DrawImage(_otherImage, x, y);
}
Thank you
@JimBobSquarePants We call this Compose in ImageMagick. Maybe we should add a Compose Sampler? I can add this.
There's no 2D drawing in ImageProcessor yet.....
I have an open ticket #264 that would cover paths etc but that still has work to do. Whatever we make I want it to be feature rich, easy to use and powerful. The architecture would be difference from the standard samplers.
This is not drawing text/paths. Its drawing one image on top of another image. In other words copy pixels from the source image to the destination image. I would prefer to do this in a Compose sampler so we could add features like only copying one channel.
@dlemstra I'd actually like to have a look at splitting channels. The blend processor can merge based on lerping but that's all or nothing.
using (Graphics g = Graphics.FromImage(_resultImage)) { g.DrawImage(_otherImage, x, y); }
Create an ImageFactory using a Stream (wherever you got _otherImage, or save _otherImage to a MemoryStream)...
_otherImageFactory.Overlay(
new ImageLayer
{
Image = _resultImage,
Position = new System.Drawing.Point(x, y)
}
);
Maybe Overlay needs more parameters?
THATS NOT CORE
No need to shout. Other projects make it a little more obvious by having distinct repositories.
using (FileStream streamFoo = File.OpenRead(@"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates\Extensibility\1033\VSShellTemplate\VSShellStubExe\Documentation\Images\AppEnv.jpg"))
using (FileStream streamBar = File.OpenRead(@"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\InstallShield\InstallShieldProject\1033\IS-text-200wide.jpg"))
using (FileStream output = File.OpenWrite(@"C:\Users\aam00\Desktop\foobar2.jpg"))
{
Image imageFoo = new Image(streamFoo);
Image imageBar = new Image(streamBar);
imageFoo.Blend(imageBar, 100);
imageFoo.Save(output);
}
This works, overlaying at (0,0).

This fails silently if the file already exists. Setting the stream length to 0 doesn't truncate it.
I also tried positioning the overlay:
imageFoo.Blend(imageBar, 100, new Rectangle(50, 30, imageBar.Width, imageBar.Height));
The Rectangle parameter doesn't behave as expected. Rather than being sizing for the positioned image, the width and height seem to crop the overlay relative to (0,0).

Sorry, didn't mean to. Was on my phone. Will have a proper look when I get to a desktop.
@Emyr42 You're absolutely correct. We need another parameter, most likely a rectangle, the first rectangle signifies the area of interest of the image to blend. The second would represent to location to drop the image.
My thought would be that if the second rectangle dimensions do not match that of the source image we would scale it.
What do you think?
Oh @Emyr42 meant to ask,
This fails silently if the file already exists. Setting the stream length to 0 doesn't truncate it.
What do you mean by this?
This issue was moved to JimBobSquarePants/ImageSharp#14
Most helpful comment
No need to shout. Other projects make it a little more obvious by having distinct repositories.