PDA

View Full Version : JPEG



sabloger
شنبه 16 بهمن 1389, 23:23 عصر
سلام دوستان
من بسیار علاقمند به آگاهی از طریقه انکودینگ و دیکدینگ JPEG و یا هر نوع تصویر دیگه هستم
اگه دوستان اطلاعاتی دارن یا رفرنسی سراغ دارن لطفاً بگذارن که هم بنده و هم بقیه بتونن استفاده کنن
باتشکرات فراوانات!!!:قلب:

system32
شنبه 16 بهمن 1389, 23:50 عصر
سلام دوست عزیز:

تابع دیکدر


// Open a Stream and decode a JPEG image
Stream imageStreamSource = new FileStream("tulipfarm.jpg", FileMode.Open, FileAccess.Read, FileShare.Read);
JpegBitmapDecoder decoder = new JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];

// Draw the Image
Image myImage = new Image();
myImage.Source = bitmapSource;
myImage.Stretch = Stretch.None;
myImage.Margin = new Thickness(20);

تابع اینکدر



int width = 128;
int height = width;
int stride = width / 8;
byte[] pixels = new byte[height * stride];

// Define the image palette
BitmapPalette myPalette = BitmapPalettes.Halftone256;

// Creates a new empty image with the pre-defined palette
BitmapSource image = BitmapSource.Create(
width,
height,
96,
96,
PixelFormats.Indexed1,
myPalette,
pixels,
stride);

FileStream stream = new FileStream("new.jpg", FileMode.Create);
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
encoder.FlipHorizontal = true;
encoder.FlipVertical = false;
encoder.QualityLevel = 30;
encoder.Rotation = Rotation.Rotate90;
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(stream);

sabloger
یک شنبه 17 بهمن 1389, 00:02 صبح
تشکر از شما دوست عزیز
اما اگه یه توضیحی در موردش بدین ممنون میشم
این که جطور کار میکنه و..

البته بنده بیشتر از این دنبال الگوریتم هاش هستم، اینکه چطور خودم تابعشو بنویسم و با دنیاش آشنا بشم :لبخند:

system32
یک شنبه 17 بهمن 1389, 00:17 صبح
به لینک زیر مراجعه کنید http://barnamenevis.org/showthread.php?20560-%D8%AF%D8%B1%D8%B3-%D8%AF%D9%88%D9%85-Compressor-Packer-Encryptor&p=109727&viewfull=1#post109727