Lab 4 - Graphics

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Lab 4 - Graphics as PDF for free.

More details

  • Words: 451
  • Pages: 18
   

System.Drawing Lucru cu obiecte de desenare Lucru cu imagini Lucru cu text

2

System.Drawing

Drawing2D Bitmap

Color, Point Size, Rectangle Brush

Font

Pen

Icon

Image

Graphics Metafile

SystemBrushes SystemColors SystemFonts SystemPans SystemIcons

3



Color  Metode statice: FromArgb, FromName

  

Point, PointF (prop: IsEmpty) Size, SizeF Rectangle, RectangleF

4

 

Linie,curba cu o anumita grosime si stil Proprietati      

Color, Width DashOffset, DashPattern StartCap, StopCap DashCap: Flat, Round, Triangle DashStyle: Dash, Dot, DashDot, DashDotDot LineCap: Flat, Round, Triangle … 5

 

Clasa abstracta Obiectul se obtine din:       

HatchBrush LinearGradientBrush PathGradientBrush SolidBrush TextureBrush Brushes SystemBrushes 6

 

Nu se poate deriva sau instantia Obiectul se obtine cu:  CreateGraphics  FromImage



Furnizeaza metode pentru desenare    

Clear DrawEllipse, DrawImage, DrawLine, DrawLines DrawPath, DrawPie, DrawPolygon, DrawRectangle DrawString, FillPolygon, FillEllipse, FillRectangle 7

Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Red, 3); p.DashPattern = new float[4] { 1, 2, 3, 2 }; p.EndCap = LineCap.DiamondAnchor; p.StartCap = LineCap.RoundAnchor; g.DrawLine(p, 10, 10, 100, 100); g.DrawBezier(p, 10, 10, 300, 70, 70, 30, 50, 50); Brush b = new LinearGradientBrush(new Point(60, 60), new Point(100, 100), Color.Red, Color.Blue); g.FillPie(b, new Rectangle(80, 100, 100, 120), 0, 300); 8

9

    

Clasa abstracta Creare, modificare, incarcare, salvare de imagini Obiectul se obtine din: FromFile, FromStream Ofera suport pentru clasele Bitmap, Metafile Afisare se face cu:  Proprietatea BackgroundImage de la control  Metoda DrawImage de la Graphics 10



Editarea:  Cu obiectul de tip Graphics



Salvare:  Metoda Save  Fomat de salvare: Bmp, Gif, Icon, Jpeg, Tiff

11



Se creaza obiectul din:  image, stream, file, blank



Metode  GetPixel, SetPixel  RotateFlip(RotateFlipType ) b.SetPixel(Color.Red,10,10); b.RotateFlip(RotateFlipType.Rotate180FlipY);

12

Bitmap bitmap = new Bitmap("d:\\map.jpg"); this.BackgroundImage = bitmap; Graphics g = Graphics.FromImage(bitmap); g.DrawLine(new Pen(Color.Red, 2), 0, bitmap.Height 20, bitmap.Width, bitmap.Height - 20); g.DrawLine(new Pen(Color.FromArgb(200, Color.Red)), 0, bitmap.Height - 5, bitmap.Width, bitmap.Height 5); g.DrawIcon(SystemIcons.Error, 40, 40); bitmap.Save("d:\\map2.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); 13

14



Afisare, desenare mesaj  Graphics.DrawString  Parametri: String, Font, Brush, PointF | RectangleF StringFormat



Clasa Font  Constructor  String | FontFamily , Dimensiune, FontStyle  ex: new Font(“Arial”,12,FontStyle.Bold ) 15



Proprietati:  Alignment – alinierea orizontala a textului  StringAlignment: Center, Near, Far

 FormatFlags – proprietati  StringFormatFlags: DirectionRightToLeft, NoClip DirectionVertical, NoFontFallback, LineLimit

 LineAlignment – alinierea verticala  StringFormat: … 16

 Trimming – mod de afisare  StringTrimming: Character, EllipsisCharacter, EllipsisPath, EllipsisWord, None, Word

Font f = new Font("Arial", 18, FontStyle.Bold); string str = "MAP TUIASI"; StringFormat sf = new StringFormat(); sf.FormatFlags = StringFormatFlags.DirectionVertical; g.DrawString(str, f, Brushes.Blue, 40, 70, sf); 17

18

Related Documents

Lab 4 - Graphics
May 2020 1
Graphics Lab Bca35l
November 2019 1
Graphics Lab Mca55l
November 2019 1
Graphics
November 2019 36
Graphics
May 2020 21
Lab 4
April 2020 9