Beispiel #1
0
 public static PPCollection LoadCollection(string zipFilename)
 {
     using (Package package = Package.Open(zipFilename, FileMode.Open))
     {
         if (!package.PartExists(URI_PART_COLLECTION))
         {
             throw new FileFormatException("Collection zip file does not include list of projects.");
         }
         string[] projectFileNames = package.GetPart(URI_PART_COLLECTION).GetStream().StreamToByteArray().ByteArrayToText().Where(x => !String.IsNullOrEmpty(x)).ToArray();
         WithoutHaste.Drawing.Colors.ColorPalette colorPalette = null;
         if (package.PartExists(URI_PART_PALETTE))
         {
             string[]  paletteLines = package.GetPart(URI_PART_PALETTE).GetStream().StreamToByteArray().ByteArrayToText();
             FormatGPL gpl          = new FormatGPL(paletteLines);
             colorPalette = gpl.ColorPalette;
         }
         PPConfig config = null;
         if (package.PartExists(URI_PART_CONFIG))
         {
             string[] configLines = package.GetPart(URI_PART_CONFIG).GetStream().StreamToByteArray().ByteArrayToText();
             config = new PPConfig(configLines);
         }
         return(new PPCollection(projectFileNames, config, colorPalette));
     }
 }
Beispiel #2
0
 public PPProject(Bitmap greyscaleBitmap, Bitmap colorBitmap, ColorPalette colorPalette)
 {
     GreyscaleBitmap = greyscaleBitmap;
     ColorBitmap     = colorBitmap;
     ColorPalette    = colorPalette;
     Config          = null;
 }
Beispiel #3
0
 public PPProject(Bitmap greyscaleBitmap, Bitmap colorBitmap, PPConfig config)
 {
     GreyscaleBitmap = greyscaleBitmap;
     ColorBitmap     = colorBitmap;
     ColorPalette    = null;
     Config          = config;
 }
Beispiel #4
0
        /// <summary>
        /// Load new project from an image file.
        /// </summary>
        /// <returns>Returns True if image is greyscale, False if image is colored.</returns>
        public bool LoadImage(string fullFileName)
        {
            Bitmap bitmap = ImageHelper.SafeLoadBitmap(fullFileName);

            if (bitmap.Width == 0 && bitmap.Height == 0)
            {
                throw new NotSupportedException("Cannot operate on a 0-pixel by 0-pixel bitmap.");
            }

            ColorPalette = null;
            Config       = new PPConfig();
            bool imageIsGreyscale = Utilities.BitmapIsGreyscale(bitmap);

            if (imageIsGreyscale)
            {
                GreyscaleBitmap = bitmap;
                ColorBitmap     = new Bitmap(bitmap);
            }
            else
            {
                GreyscaleBitmap = null;                 //todo: cannot save until this is set to a bitmap
                ColorBitmap     = bitmap;
            }
            EditedSinceLastSave = true;
            SaveToFileName      = null;        //do not assume file name should be the same as the image file name
            LoadedFromFileName  = fullFileName;

            return(imageIsGreyscale);
        }
 /// <summary>
 /// Create new collection from existing data.
 /// </summary>
 public PPCollection(string[] projectFileNames, PPConfig config, ColorPalette colorPalette)
 {
     Config = config;
     foreach (string projectFileName in projectFileNames)
     {
         LoadProject_Internal(projectFileName);
     }
     ColorPalette = colorPalette;
 }