TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C# Drawing: Images and Fonts

These C# articles cover the System.Drawing namespace. They explore Image, Size, Point and Font.

Drawing. The System.Drawing namespace provides graphical capabilities.

With its tools, we manipulate and create visual effects. We handle images and primitive shapes. The Image and Font types are among the most important.

Image. This console program opens an image with the Image.FromFile method. It then prints the size of the image to the console. The Image type makes working with image data, such as PNG and JPG, easier.

Image

Tip: If the program doesn't compile, try adding the assembly reference System.Drawing in Visual Studio.

Bitmaps: Images are usually stored as bitmaps, which represent collections of colored pixels. They can also store translucency values.

Thumbnails: Thumbnail images can be created with the Image type. We provide details and examples.

Thumbnail Image

Based on:

.NET 4

C# program that uses Image, System.Drawing namespace

using System;
using System.Drawing;

class Program
{
    static void Main()
    {
	Image image = Image.FromFile("C:\\background1.png");
	Console.WriteLine(image.Size);
    }
}

Output

{Width=180, Height=110}

Colors are the end result of how the light receptors in our eyes interact with our computer monitors. Also, things in the outside world apparently have colors too. We describe the Color type in the System.Drawing namespace.

Color

Console: The console also supports colors. These are specified with a separate, ConsoleColor enum type.

Console Colors

Sizes, Points. If you want to draw shapes on a two-dimensional surface, you will need sizes and points. These are made up of integers and floating-point numbers. Size has integer coordinates. SizeF has floating-point coordinates.

Size, SizeF

Point: A Size stores a width and a height. A Point instead stores just two coordinates: X and Y.

Point, PointF

Font. The Font type is also found in the System.Drawing namespace. We describe some interesting techniques of handling fonts in your programs, beginning with the Font type itself. We test a typeface's existence by using the constructor.

Font

WPF. The WPF Framework supports drawing operations. With some controls, such as Ellipse, we draw shapes. And with the RenderTransform element, we can apply dynamic transformations to these shapes.

EllipseRenderTransformWPF

Summary. These tips will not make it possible to create elaborate graphics, but they emphasize some important things about the System.Drawing namespace in the .NET Framework. Complex three-dimensional rendering requires more advanced libraries.


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf