This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
lauren@photoboothsupplyco.com  
#1 Posted : Thursday, August 3, 2017 11:04:25 AM(UTC)
lauren@photoboothsupplyco.com

Rank: Member

Groups: Guest
Joined: 7/30/2017(UTC)
Posts: 18

Thanks: 7 times
Hi,

Is there a way to load a PSD file, then convert it to a Bitmap file so that I can then show the image within my application?

Thanks

Fedor  
#2 Posted : Thursday, August 3, 2017 6:33:25 PM(UTC)
Fedor

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)
Yes, sure, you can load a PSD file:

Code:
using System;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Codecs.Psd;

class Program
{
	static void Main(string[] args)
	{
		using (var reader = new PsdReader("../../../BusinessCard.psd"))
		{
			if (reader.MergedImageFrame != null)
			{
				using (var bitmap = reader.MergedImageFrame.GetBitmap())
				{
					bitmap.Save("../../../out.jpg");
				}
			}
			else
			{
				using (var bitmap = reader.MergeLayers())
				{
					bitmap.Save("../../../out.jpg");
				}
			}
		}
	}
}

You can even personalize PSD templates.

Best regards,

Fedor Skvortsov

thanks 1 user thanked Fedor for this useful post.
lauren@photoboothsupplyco.com  
#3 Posted : Saturday, August 5, 2017 4:38:17 PM(UTC)
lauren@photoboothsupplyco.com

Rank: Member

Groups: Guest
Joined: 7/30/2017(UTC)
Posts: 18

Thanks: 7 times
Thank you for the quick answers. Along the same line, if I do personalize the psd using a PsdProcessor, how can I then turn that into a bitmap to show on screen?
Andrey Semenov  
#4 Posted : Monday, August 7, 2017 3:27:10 AM(UTC)
Andrey Semenov

Rank: Advanced Member

Groups: Guest
Joined: 7/4/2017(UTC)
Posts: 43

Was thanked: 12 time(s) in 12 post(s)
To turn the content of PsdProcessor into image to show on screen, Render() method can be used:

Code:
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Templates;

class Program
{
    static void Main(string[] args)
    {
        var psdProcessor = new PsdProcessor();
        // Your personalization code goes here
        // ...
        psdProcessor.Render("businesscard.psd", "businesscard.png");

        // Create Bitmap object from resulting file, if some specific functionality of this class is required
       var bitmap = new Bitmap("businesscard.png");
    }
}

Regards,

Andrew

Edited by user Monday, August 7, 2017 3:52:15 AM(UTC)  | Reason: Not specified

Fedor  
#5 Posted : Monday, August 7, 2017 8:41:38 PM(UTC)
Fedor

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)
You can use the following code to create a bitmap without using a temporary file:

Code:
using (var psdReader = new PsdReader("../../../BusinessCard.psd"))
using (var container = new GraphicsContainer(psdReader.Width, psdReader.Height, 
	psdReader.DpiX, psdReader.DpiY))
{
	var psdProcessor = new PsdProcessor();
	psdProcessor.Render(psdReader, container);

	using (var bitmap = new Bitmap(psdReader.Width, psdReader.Height, psdReader.PixelFormat))
	{
		bitmap.DpiX = psdReader.DpiX;
		bitmap.DpiY = psdReader.DpiY;

		using (var graphics = bitmap.GetAdvancedGraphics())
		{
			graphics.DrawContainer(container, 0f, 0f);
		}

		bitmap.Save("../../../out2.jpg");
	}
}
Best regards,

Fedor Skvortsov

thanks 1 user thanked Fedor for this useful post.
lauren@photoboothsupplyco.com on 8/10/2017(UTC)
Users browsing this topic
Guest (2)
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.