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
|
|
|
|
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
|
1 user thanked Fedor for this useful post.
|
|
|
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?
|
|
|
|
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
|
|
|
|
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
|
1 user thanked Fedor for this useful post.
|
|
|
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.