예제 #1
0
        //add png specific method later
        public static void Write(Image img, string filePath)
        {
            DLLImports.gdImageSaveAlpha(img.gdImageStructPtr, 1);

            if (!DLLImports.gdSupportsFileType(filePath, true))
            {
                throw new InvalidOperationException(SR.Format(SR.FileTypeNotSupported, filePath));
            }
            else
            {
                if (!DLLImports.gdImageFile(img.gdImageStructPtr, filePath))
                {
                    throw new FileLoadException(SR.Format(SR.WriteToFileFailed, filePath));
                }
            }
        }
예제 #2
0
        //add jpg specific method later
        public static Image Load(string filePath)
        {
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(string.Format(Strings.MalformedFilePath, filePath));
            }
            else if (DLLImports.gdSupportsFileType(filePath, false))
            {
                Image img = new Image(DLLImports.gdImageCreateFromFile(filePath));

                if (!img.TrueColor)
                {
                    DLLImports.gdImagePaletteToTrueColor(img.gdImageStructPtr);
                }
                return(img);
            }
            else
            {
                throw new FileLoadException(string.Format(Strings.FileTypeNotSupported, filePath));
            }
        }