1 / 10

Računarska grafika

Računarska grafika. GDI+ ( Graphics Device Interface Plus). Metafiles in GDI+.

gad
Download Presentation

Računarska grafika

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Računarska grafika GDI+ (Graphics Device Interface Plus)

  2. Metafiles in GDI+ • GDI+ provides the Metafile class so that you can record and display metafiles. A metafile, also called a vector image, is an image that is stored as a sequence of drawing commands and settings. The commands and settings recorded in a Metafileobject can be stored in memory or saved to a file or stream. • GDI+ can display metafiles that have been stored in the following formats: • Windows Metafile (WMF) • Enhanced Metafile (EMF) • EMF+ • EMF+ Only (GDI+ only) • EMF+ Dual (GDI & GDI+ - dual records) *GDI+ can record metafiles in the EMF and EMF+ formats, but not in the WMF format.

  3. Metafiles in GDI+ • Metafiles contain information about how an image was created - including lists of graphics operations - rather than storing the image in pixel format. Graphics operations in a metafile are stored as records, which can be controlled (recorded and played back) individually. • The Metafile class provides about 40 overloaded forms of its constructor. • Loading and viewing a metafile is similar to viewing a bitmap. An application can load a metafile from a stream, string, or IntPtr instance with different formats and locations. The simplest way to load and view a metafile is to pass the file name in the Metafile constructor and call DrawImage.

  4. Metafile Class • The Metafile class is derived from the Image class has no methods and properties beside those inherited from the Image class. • the Metafile class provides a long list of overloaded constructor. It also provides three methods: • GetHenhMetafile • returns a window handle to a metafile • GetMetafileHeader • which has five overloaded forms, returns a metafile header in the form of a MetafileHeader object.  • PlayRecord. • plays (reads and displays) an extended metafile.

  5. Metafile Class • Metafile( string filename) • filename • A String that represents the file name from which to create the new Metafile.  • Metafile( string fileName, IntPtrreferenceHdc) • fileName • A String that represents the file name of the newMetafile.  • referenceHdc • A Windows handle to a device context. 

  6. Example Graphics g = e.Graphics; g.Clear(this.BackColor); IntPtrhdc = g.GetHdc(); Metafile metafajlic = new Metafile(@"C:\Documents and Settings\Ognjen\Desktop\RG\test.emf", hdc); Graphics g1 = Graphics.FromImage(metafajlic); g1.SmoothingMode = SmoothingMode.HighQuality; Rectangle kvadratic = new Rectangle(0, 0, 200, 200); g1.FillRectangle(Brushes.Green, kvadratic); kvadratic.Y += 110; LinearGradientBrushcetkica = new LinearGradientBrush(kvadratic, Color.Red, Color.Blue, 45.0f); g1.FillEllipse(cetkica, kvadratic);

  7. Example kvadratic.Y += 110; g1.DrawString("Računarskagrafika, I.Sarajevo\nMetaFile test", new Font("Verdana", 20), cetkica, 200, 200, StringFormat.GenericTypographic); g.ReleaseHdc(hdc); metafajlic.Dispose(); metafajlic = new Metafile(@"C:\Documents and Settings\Ognjen\Desktop\RG\test.emf"); g.DrawImage(metafajlic, 0, 0); metafajlic.Dispose(); g1.Dispose();

  8. Example Bitmap slicica = new Bitmap(616, 310); g1 = Graphics.FromImage(slicica); g1.SmoothingMode = SmoothingMode.HighQuality; kvadratic = new Rectangle(0, 0, 200, 200); g1.FillRectangle(Brushes.Green, kvadratic); kvadratic.Y += 110; g1.FillEllipse(cetkica, kvadratic); kvadratic.Y += 110; g1.DrawString("Računarskagrafika, I.Sarajevo\nMetaFile test", new Font("Verdana", 20), cetkica, 200, 200, StringFormat.GenericTypographic);

  9. Example slicica.Save(@"C:\Documents and Settings\Ognjen\Desktop\RG\testic.bmp", ImageFormat.Bmp); slicica.Save(@"C:\Documents and Settings\Ognjen\Desktop\RG\testic.jpg", ImageFormat.Jpeg); slicica.Save(@"C:\Documents and Settings\Ognjen\Desktop\RG\testic.gif", ImageFormat.Gif); slicica.Save(@"C:\Documents and Settings\Ognjen\Desktop\RG\testic.png", ImageFormat.Png); slicica.Save(@"C:\Documents and Settings\Ognjen\Desktop\RG\testic.emf", ImageFormat.Emf); g.DrawImage(slicica, 0, 350); g1.Dispose(); g.Dispose();

  10. Example

More Related