Exemplo n.º 1
0
 public virtual FileMap EncodeREFTTextureIndexed(Bitmap src, int mipLevels, int numColors,
                                                 WiiPaletteFormat format, QuantizationAlgorithm algorithm)
 {
     using (Bitmap indexed = src.Quantize(algorithm, numColors, RawFormat, format, null))
     {
         return(EncodeREFTTextureIndexed(indexed, mipLevels, format));
     }
 }
Exemplo n.º 2
0
 public virtual FileMap EncodeTPLTextureIndexed(Bitmap src, int numColors, WiiPaletteFormat format,
                                                QuantizationAlgorithm algorithm, out FileMap paletteFile)
 {
     using (Bitmap indexed = src.Quantize(algorithm, numColors, RawFormat, format, null))
     {
         return(EncodeTPLTextureIndexed(indexed, 1, format, out paletteFile));
     }
 }
Exemplo n.º 3
0
        //public static unsafe ColorPalette GeneratePalette(this Bitmap bmp, QuantizationAlgorithm mode, int numColors)
        //{
        //    ColorInformation info = bmp.GetColorInformation();

        //    ColorPalette pal = ColorPaletteExtension.CreatePalette(ColorPaletteFlags.None, numColors);
        //    if (info.UniqueColors.Length <= numColors)
        //    {
        //        //Use original colors
        //        for (int i = 0; i < info.UniqueColors.Length; i++)
        //            pal.Entries[i] = (Color)info.UniqueColors[i];
        //    }
        //    else
        //    {
        //        switch (mode)
        //        {
        //            case QuantizationAlgorithm.WeightedAverage:
        //                {
        //                    pal = WeightedAverage.Process(bmp, numColors);
        //                    break;
        //                }
        //            //case QuantizationAlgorithm.MedianCut:
        //            //    {
        //            //        MedianCut.Quantize(bmp, numColors);
        //            //        break;
        //            //    }
        //        }
        //    }
        //    return pal;
        //}

        public static Bitmap Quantize(this Bitmap bmp, QuantizationAlgorithm algorithm, int numColors, WiiPixelFormat texFormat, WiiPaletteFormat palFormat, IProgressTracker progress)
        {
            return(MedianCut.Quantize(bmp, numColors, texFormat, palFormat, progress));
        }
 //public static unsafe ColorPalette GeneratePalette(this Bitmap bmp, QuantizationAlgorithm mode, int numColors)
 //{
 //    ColorInformation info = bmp.GetColorInformation();
 //    ColorPalette pal = ColorPaletteExtension.CreatePalette(ColorPaletteFlags.None, numColors);
 //    if (info.UniqueColors.Length <= numColors)
 //    {
 //        //Use original colors
 //        for (int i = 0; i < info.UniqueColors.Length; i++)
 //            pal.Entries[i] = (Color)info.UniqueColors[i];
 //    }
 //    else
 //    {
 //        switch (mode)
 //        {
 //            case QuantizationAlgorithm.WeightedAverage:
 //                {
 //                    pal = WeightedAverage.Process(bmp, numColors);
 //                    break;
 //                }
 //            //case QuantizationAlgorithm.MedianCut:
 //            //    {
 //            //        MedianCut.Quantize(bmp, numColors);
 //            //        break;
 //            //    }
 //        }
 //    }
 //    return pal;
 //}
 public static Bitmap Quantize(this Bitmap bmp, QuantizationAlgorithm algorithm, int numColors, WiiPixelFormat texFormat, WiiPaletteFormat palFormat, IProgressTracker progress)
 {
     return MedianCut.Quantize(bmp, numColors, texFormat, palFormat, progress);
 }
Exemplo n.º 5
0
        //public virtual void GeneratePreviewIndexed(Bitmap src, Bitmap dst, int numColors, WiiPaletteFormat format)
        //{
        //    _cachedPalette = src.GeneratePalette(QuantizationAlgorithm.WeightedAverage, numColors);
        //    _paletteFormat = format;
        //    _cachedPalette.Clamp(format);

        //    src.CopyTo(dst);
        //    dst.Clamp(_cachedPalette);
        //}

        //public virtual void GeneratePreview(Bitmap src, Bitmap dst)
        //{
        //    src.CopyTo(dst);
        //    dst.Clamp(RawFormat);
        //}

        public virtual FileMap EncodeTextureIndexed(Bitmap src, int mipLevels, int numColors, WiiPaletteFormat format, QuantizationAlgorithm algorithm, out FileMap paletteFile)
        {
            using (Bitmap indexed = src.Quantize(algorithm, numColors, RawFormat, format, null))
            {
                return(EncodeTextureIndexed(indexed, mipLevels, format, out paletteFile));
            }
            //ColorPalette pal = src.GeneratePalette(algorithm, numColors);
            //pal.Clamp(format);
            //return EncodeTextureIndexed(src, mipLevels, pal, format, out paletteFile);
        }
 public virtual FileMap EncodeTPLTextureIndexed(Bitmap src, int numColors, WiiPaletteFormat format, QuantizationAlgorithm algorithm, out FileMap paletteFile)
 {
     using (Bitmap indexed = src.Quantize(algorithm, numColors, RawFormat, format, null))
         return EncodeTPLTextureIndexed(indexed, 1, format, out paletteFile);
 }
 public virtual FileMap EncodeREFTTextureIndexed(Bitmap src, int mipLevels, int numColors, WiiPaletteFormat format, QuantizationAlgorithm algorithm)
 {
     using (Bitmap indexed = src.Quantize(algorithm, numColors, RawFormat, format, null))
         return EncodeREFTTextureIndexed(indexed, mipLevels, format);
 }