Advertisement
qwertz19281

C# read GFIE document as Image

Oct 30th, 2017
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. /**
  2.  * Read a GFIE (Greenfish Icon Editor Pro) document and draws it to a image
  3.  * Currently supports:
  4.  * - Multiple Layers
  5.  * - Layer Visibility
  6.  * Currently doesn't supports:
  7.  * - Pages
  8.  * - Layer Opacity and Blend Mode
  9.  *
  10.  * Depedencies
  11.  *
  12.  * GFIEFormat class from Greenfish Image Converter
  13. */
  14. Bitmap gfieToImg(string file,int page){
  15.     GfieDocument doc = new GfieDocument();
  16.     doc.LoadAsGfie(file);
  17.     GfieDocument.LayerCollection ls = doc.Pages[page].Layers;
  18.     Bitmap bmp=new Bitmap(ls.Width,ls.Height);
  19.     Graphics g=Graphics.FromImage(bmp);
  20.     for(int i=(ls.Layers.Count-1);i>=0;i--){
  21.         GfieDocument.Layer ly=ls.Layers[i];
  22.         if(ly.Visible&&ly.Opacity>127){
  23.             g.DrawImageUnscaled(ly.Image.Image,0,0);
  24.         }
  25.     }
  26.     g.Flush();
  27.     return bmp;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement