Silverlight类库介绍-FJCore
FJCore是一个图片编码类库(目前只有对JPEG格式的支持)。
设计目标:
-精简,没有外部依赖-高性能-图片高清晰-使用便捷
代码
using
(fileStream)
{
// Decode
DecodedJpeg jpegIn = new JpegDecoder(fileStream).Decode();
// Resize
DecodedJpeg jpegOut = new DecodedJpeg(
new ImageResizer(jpegIn.Image)
.Resize( 320 , ResamplingFilters.LowpassAntiAlias),
jpegIn.MetaHeaders); // 保留EXIF信息
// Encode
MemoryStream outStream = new MemoryStream();
new JpegEncoder(jpegOut, 90 , outStream).Encode();
// Display
outStream.Seek( 0 , SeekOrigin.Begin);
BitmapImage image = new BitmapImage();
image.SetSource(outStream);
OutputImage.Source = image;
}
{
// Decode
DecodedJpeg jpegIn = new JpegDecoder(fileStream).Decode();
// Resize
DecodedJpeg jpegOut = new DecodedJpeg(
new ImageResizer(jpegIn.Image)
.Resize( 320 , ResamplingFilters.LowpassAntiAlias),
jpegIn.MetaHeaders); // 保留EXIF信息
// Encode
MemoryStream outStream = new MemoryStream();
new JpegEncoder(jpegOut, 90 , outStream).Encode();
// Display
outStream.Seek( 0 , SeekOrigin.Begin);
BitmapImage image = new BitmapImage();
image.SetSource(outStream);
OutputImage.Source = image;
}