/// <summary> /// Ignores modifyLayer - not supported by this renderer. /// </summary> /// <param name="s"></param> /// <param name="textLayers"></param> /// <param name="showLayerCallback"></param> /// <param name="modifyLayer"></param> /// <returns></returns> public System.Drawing.Bitmap Render(Stream s, out IList<IPsdLayer> layers, RenderLayerDelegate showLayerCallback, ModifyLayerDelegate modifyLayer) { // Create the resultBitmap object which contains merged bitmap, // and the currentBitmap object which contains current bitmap during iteration. // These object enable you to operate with layers. Aurigma.GraphicsMill.Bitmap resultBitmap = new Aurigma.GraphicsMill.Bitmap(); using (Aurigma.GraphicsMill.Bitmap currentBitmap = new Aurigma.GraphicsMill.Bitmap()) { // Create advanced PSD reader object to read .psd files. using (Aurigma.GraphicsMill.Codecs.AdvancedPsdReader psdReader = new Aurigma.GraphicsMill.Codecs.AdvancedPsdReader(s)) { // Load the background layer which you will put other layers on. // Remember that the layer on zero position should be skiped // because it contains merged bitmap. Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame frame; using (frame = (Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame)psdReader.LoadFrame(1)) { frame.GetBitmap(resultBitmap); } //List of layers layers = new List<IPsdLayer>(); //This code merges the rest layers with the background layer one by one. for (int i = 2; i < psdReader.FrameCount; i++) { using (frame = (Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame)psdReader.LoadFrame(i)) { // Do not forget to verify the unknown layer type. if (frame.Type != Aurigma.GraphicsMill.Codecs.PsdFrameType.Unknown) { //Add layers layers.Add(new PsdLayer(frame, i + 1)); bool showFrame = showLayerCallback(i - 1, frame.Name, frame.Visible); //Subtract 1 from index so layer 0 is the background layer if (showFrame) { // Extract the current image from the layer. frame.GetBitmap(currentBitmap); // Draw current layer on the result bitmap. // Also check out if the layer is visible or not. // If the layer is invisible we skip it. currentBitmap.Draw(currentBitmap, frame.Left, frame.Top, frame.Width, frame.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, 1, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighQuality); } } } } } } return resultBitmap.ToGdiplusBitmapDirectly(); }
public ScriptRenderLayer(RenderLayerDelegate script, Vector2 parallax, String name) : base(parallax, name) { this.script = script; data = null; }
public ScriptRenderLayer(RenderLayerDelegate script, bool fixed_pos, String name) : this(script, ( fixed_pos ? VERGEMap.FIXED_PARALLAX : VERGEMap.NEUTRAL_PARALLAX ), name) { }
public ScriptRenderLayer(RenderLayerDelegate script, String name) : this(script, VERGEMap.FIXED_PARALLAX, name) { }
public ScriptRenderLayer() : base(VERGEMap.FIXED_PARALLAX, "Hook Render") { script = new RenderLayerDelegate(VERGEGame.game.call_render_hook); data = null; }