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

Notification

Icon
Error

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

Rank: Newbie

Groups: Member
Joined: 7/30/2017(UTC)
Posts: 6

Thanks: 3 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 03, 2017 6:33:25 PM(UTC)
Fedor

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 58 time(s) in 57 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 05, 2017 4:38:17 PM(UTC)
lauren@photoboothsupplyco.com

Rank: Newbie

Groups: Member
Joined: 7/30/2017(UTC)
Posts: 6

Thanks: 3 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 07, 2017 3:27:10 AM(UTC)
Andrey Semenov

Rank: Newbie

Groups: Member, Administration
Joined: 7/4/2017(UTC)
Posts: 5

Was thanked: 1 time(s) in 1 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 07, 2017 3:52:15 AM(UTC)  | Reason: Not specified

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

Rank: Advanced Member

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

Thanks: 5 times
Was thanked: 58 time(s) in 57 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
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.