ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Classes | Public Member Functions | List of all members
ImageResizer.Plugins.PsdComposer.GraphicsMillRenderer Class Reference

An Aurigma.GraphicsMill-based renderer. GraphicsMill was far too limited to do what we needed, so this got scrapped. More...

Inheritance diagram for ImageResizer.Plugins.PsdComposer.GraphicsMillRenderer:
Inheritance graph
[legend]
Collaboration diagram for ImageResizer.Plugins.PsdComposer.GraphicsMillRenderer:
Collaboration graph
[legend]

Public Member Functions

System.Drawing.Bitmap Render (Stream s, out IList< IPsdLayer > layers, RenderLayerDelegate showLayerCallback, ModifyLayerDelegate modifyLayer)
 Ignores modifyLayer - not supported by this renderer. More...
 
IList< IPsdLayerGetLayers (Stream s)
 
- Public Member Functions inherited from ImageResizer.Plugins.PsdComposer.IPsdRenderer
Bitmap Render (Stream s, out IList< IPsdLayer > layers, out Size size, ShowLayerDelegate showLayerCallback, ComposeLayerDelegate modifyLayer)
 
IList< IPsdLayerGetLayersAndSize (Stream s, out Size size)
 

Detailed Description

An Aurigma.GraphicsMill-based renderer. GraphicsMill was far too limited to do what we needed, so this got scrapped.

Definition at line 12 of file GraphicsMillRenderer.cs.

Member Function Documentation

System.Drawing.Bitmap ImageResizer.Plugins.PsdComposer.GraphicsMillRenderer.Render ( Stream  s,
out IList< IPsdLayer layers,
RenderLayerDelegate  showLayerCallback,
ModifyLayerDelegate  modifyLayer 
)
inline

Ignores modifyLayer - not supported by this renderer.

Parameters
s
textLayers
showLayerCallback
modifyLayer
Returns

Definition at line 22 of file GraphicsMillRenderer.cs.

23  {
24  // Create the resultBitmap object which contains merged bitmap,
25  // and the currentBitmap object which contains current bitmap during iteration.
26  // These object enable you to operate with layers.
27  Aurigma.GraphicsMill.Bitmap resultBitmap = new Aurigma.GraphicsMill.Bitmap();
28  using (Aurigma.GraphicsMill.Bitmap currentBitmap = new Aurigma.GraphicsMill.Bitmap())
29  {
30  // Create advanced PSD reader object to read .psd files.
31  using (Aurigma.GraphicsMill.Codecs.AdvancedPsdReader psdReader = new Aurigma.GraphicsMill.Codecs.AdvancedPsdReader(s))
32  {
33 
34  // Load the background layer which you will put other layers on.
35  // Remember that the layer on zero position should be skiped
36  // because it contains merged bitmap.
37  Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame frame;
38  using (frame = (Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame)psdReader.LoadFrame(1))
39  {
40  frame.GetBitmap(resultBitmap);
41  }
42 
43  //List of layers
44  layers = new List<IPsdLayer>();
45 
46  //This code merges the rest layers with the background layer one by one.
47  for (int i = 2; i < psdReader.FrameCount; i++)
48  {
49  using (frame = (Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame)psdReader.LoadFrame(i))
50  {
51 
52  // Do not forget to verify the unknown layer type.
53  if (frame.Type != Aurigma.GraphicsMill.Codecs.PsdFrameType.Unknown)
54  {
55  //Add layers
56  layers.Add(new PsdLayer(frame, i + 1));
57 
58  bool showFrame = showLayerCallback(i - 1, frame.Name, frame.Visible); //Subtract 1 from index so layer 0 is the background layer
59  if (showFrame)
60  {
61  // Extract the current image from the layer.
62  frame.GetBitmap(currentBitmap);
63 
64  // Draw current layer on the result bitmap.
65  // Also check out if the layer is visible or not.
66  // If the layer is invisible we skip it.
67  currentBitmap.Draw(currentBitmap, frame.Left, frame.Top, frame.Width, frame.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, 1, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighQuality);
68 
69 
70  }
71  }
72  }
73  }
74  }
75  }
76  return resultBitmap.ToGdiplusBitmapDirectly();
77  }

The documentation for this class was generated from the following file: