منتدى قسم تكنولوجيا المعلومات في مدرسة الدوحة الثانوية المستقلة للبنين
علمت أن رزقي لن يأخذه غيري فاطمأن قلبي

قم وذق طعم الصلاة في دجى الليل الطويل

قم وجاهد في الحياة ان مثوانا قليل
منتدى قسم تكنولوجيا المعلومات في مدرسة الدوحة الثانوية المستقلة للبنين
علمت أن رزقي لن يأخذه غيري فاطمأن قلبي

قم وذق طعم الصلاة في دجى الليل الطويل

قم وجاهد في الحياة ان مثوانا قليل
منتدى قسم تكنولوجيا المعلومات في مدرسة الدوحة الثانوية المستقلة للبنين
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

منتدى قسم تكنولوجيا المعلومات في مدرسة الدوحة الثانوية المستقلة للبنين

من أفضل مدارس قطر
 
الرئيسيةأحدث الصورالتسجيلدخول
قال الامام احمد بن حنبل: إن لنا إخوان لانراهم إلا مره كل سنه , نحن اوثق بمودتهم ممن نراهم كل يوم .أسعد الله قلوبا طاهره إن وصلناها شكرت وإن قصرنا عذرت
من العظماء من يشعر المرء فى حضرته أنه صغير ولكن العظيم بحق هو من يشعر الجميع في حضرته بأنهم عظماء
كم في المقابر من يحسدونك على هذه الأيام والليالي التي تعيشها يتمنون لو تسبيحة أو استغفار ينفعهم عند ربهم أو سجدة تنير قبورهم أو صدقة تظلهم بين يدي الملك الجبار .. فقط تذكر .. ولا تضيع الفرصة التي بين يديك

 

 Working with Images

اذهب الى الأسفل 
2 مشترك
كاتب الموضوعرسالة
A.Tamimi
Admin
A.Tamimi


Posts : 1593
أهمية العضو : 16
Join date : 13/11/2008
Age : 38
Location : Jordan

Working with Images Empty
مُساهمةموضوع: Working with Images   Working with Images Emptyالأحد نوفمبر 30, 2008 2:17 am

Working with Images

Using the Image Class



The Image class is usually your first port of call when using images in .NET programming. It
enables you to store a picture in memory so that it can be manipulated, and it exposes many pieces
of information about that picture, including its size and how many colors are used. Image is the
base class from which another class, Bitmap, is derived. We'll be looking at Bitmap in a while, but
we should look at Image's capabilities first.
The Image class comes packed with lots of useful functionality, such as:


  • Loading an image from a file and exposing information about it.
  • Saving a picture to a file in a specified format such as JPEG or GIF.
  • Rotating or flipping a picture.
  • Enabling detailed manipulation of the picture by using other classes in conjunction with the Image object. For example, you can draw lines on the picture by using an associated Graphics object.


There are of course many other properties and methods of the Image class but the ones outlined
above are by far the most commonly used. To introduce the Image class we'll use three of the
above features in one go!
Besides being a programmer, I am also an amateur photographer, and I like to take personal
portraits. I often take several dozen photographs on my digital camera over the course of a day.
One problem I face is that I hold my camera at 90 degrees to the horizontal; so that I can fit the
chosen subject in the viewfinder properly.
This is annoying because all the saved pictures on my camera are stored sideways and my camera
doesn't have an auto-rotate feature. So every day I have to open all the new photographs on my
computer, rotate them by 90 degrees to make them appear the right way up and then save them
again. I like to save them as JPEG files to save space.
How could I use C# to make my life easier? Simple, just by creating a method that will rotate the
image 90 degrees.



private
void RotateAndSaveImage(String input, String output)
{
//create an object that we can use to examine an image file
Image img = Image.FromFile(input);

//rotate the picture by 90 degrees
img.RotateFlip(RotateFlipType.Rotate90FlipNone);

//re-save the picture as a Jpeg
img.Save(output, System.Drawing.Imaging.ImageFormat.Jpeg);

//tidy up after we've finished
img.Dispose();
}

That's an outline of the whole process of loading, rotating, and saving a picture, all wrapped in a
short method; exception handling and parameter validation were omitted for clarity. Let us look at
it in detail.
Firstly, the RotateAndSaveImage() method takes two string parameters: input and output. The
input parameter is the path of the picture file we want to use. The output parameter is the name
of the new file that will be created when the Image.Save() method is called.
Further I could use a for loop to iterate through all the files within a folder on my computer.
I can even try this on my camera's memory card directly and pass each filename to this
RotateAndSaveImage() method. So in doing this, I can save valuable time, being free to travel
further from home in pursuit of my hobby.

Working with Images Jewels13

ليتك تحلو والحياة مريره وليتك ترضى والانام غضاب
وليت الذى بينى وبينك عامر وبينى وبين العالمين خراب
إذا صحّ منك الود فالكل هيّن وكل الذى فوق التراب تراب

اللهم ارحم موتانا وموتى جميع المسلمين
اللهم أنزل على قبورهم الضياء والنور والفسحة والسرور وجازهم بالاحسان إحسان وبالسيئات عفوا وغفرانا

الرجوع الى أعلى الصفحة اذهب الى الأسفل
https://falcons.aforumfree.com
M.ALS3OD

M.ALS3OD


Posts : 854
أهمية العضو : 0
Join date : 13/09/2009
Age : 30
Location : AMMAN

Working with Images Empty
مُساهمةموضوع: رد: Working with Images   Working with Images Emptyالسبت سبتمبر 19, 2009 2:34 am

مـــشـــكـــورررررررررررر
الرجوع الى أعلى الصفحة اذهب الى الأسفل
 
Working with Images
الرجوع الى أعلى الصفحة 
صفحة 1 من اصل 1
 مواضيع مماثلة
-
» Working with Files in C#

صلاحيات هذا المنتدى:لاتستطيع الرد على المواضيع في هذا المنتدى
منتدى قسم تكنولوجيا المعلومات في مدرسة الدوحة الثانوية المستقلة للبنين :: ----§§§§ المنتديات التقنية والبرمجية §§§§---- :: قسم الدوت نت لتطوير الويب والديسكتوب-
انتقل الى: