• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Create a simple Paintbrush application using various GDI components.

January 20, 2012 by ProjectsGeek Leave a Comment

Create a simple Paintbrush application using various GDI components.
Aim: Create a simple Paintbrush application using various GDI components.
Theory: GDI is responsible for tasks such as drawing lines and curves, rendering fonts and handling palettes. It is not directly responsible for drawing windows, menus, etc.: that task is reserved for the user subsystem, which resides in user32.dll and is built atop GDI. GDI is similar to Apple’s classic QuickDraw.
Perhaps the most significant capability of GDI over more direct methods of accessing the hardware is its scaling capabilities, and abstraction of target devices. Using GDI, it is very easy to draw on multiple devices, such as a screen and a printer, and expect proper reproduction in each case. This capability is at the centre of all WYSIWYG applications for Microsoft Windows.
Simple games which do not require fast graphics rendering, such as Freecell or Minesweeper, use GDI. However, GDI cannot animate properly (no notion of synchronizing with the framebuffer) and lacks rasterization for 3D. Modern games use DirectX or OpenGL, which give programmers access to more hardware capabilities.
In Windows Vista, GDI applications running in the new compositing engine, Desktop Window Manager, will no longer be hardware-accelerated.
With the introduction of Windows XP, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem. GDI+ is a “next generation” 2D graphics environment, adding advanced features such as anti-aliased 2D graphics, floating point coordinates, alpha blending, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG (which were conspicuously absent in GDI), and general support for composition of affine transformations in the 2D view pipeline. Use of these features is apparent in Windows XP’s user interface, and their presence in the basic graphics layer greatly simplifies implementations of vector-graphics systems such as Flash or SVG. The GDI+ dynamic library can be shipped with an application and used under older versions of Windows.
The Microsoft .NET class library provides a managed interface for GDI+ via the System.Drawing namespace.
GDI+ is similar (in purpose and structure) to Apple’s Quartz 2D subsystem, and the open-source libart and Cairo libraries.
Microsoft Windows GDI+ draws lines, rectangles, and other figures on a coordinate system. You can choose from a variety of coordinate systems, but the default coordinate system has the origin in the upper left corner with the x-axis pointing to the right and the y-axis pointing down. The unit of measure in the default coordinate system is the pixel.
default coordinate system
A computer monitor creates its display on a rectangular array of dots called picture elements or pixels. The number of pixels appearing on the screen varies from one monitor to the next, and the number of pixels appearing on an individual monitor can usually be configured to some extent by the user.
rectangular array of pixels
When you use GDI+ to draw a line, rectangle, or curve, you provide certain key information about the item to be drawn. For example, you can specify a line by providing two points, and you can specify a rectangle by providing a point, a height, and a width. GDI+ works in conjunction with the display driver software to determine which pixels must be turned on to show the line, rectangle, or curve. The following illustration shows the pixels that are turned on to display a line from the point (4, 2) to the point (12, 8).
line, as displayed by a rectangular array of pixels
Over time, certain basic building blocks have proven to be the most useful for creating two-dimensional pictures. These building blocks, which are all supported by GDI+, are given in the following list:
    * Lines
    * Rectangles
    * Ellipses
    * Arcs
    * Polygons
    * Cardinal splines
    * Bzier splines
The Graphics class in GDI+ provides the following methods for drawing the items in the previous list: DrawLine, DrawRectangle, DrawEllipse, DrawPolygon, DrawArc, DrawCurve (for cardinal splines), and DrawBezier. Each of these methods is overloaded; that is, each method comes in several variations with different parameter lists. For example, one variation of the DrawLine method receives the address of a Pen object and four integers, while another variation of the DrawLine method receives the address of a Pen object and two Point object references.
The methods for drawing lines, rectangles, and Bzier splines have plural companion methods that draw several items in a single call: DrawLines, DrawRectangles, and DrawBeziers. Also, the DrawCurve method has a companion method, DrawClosedCurve, that closes a curve by connecting the ending point of the curve to the starting point.
All the drawing methods of the Graphics class work in conjunction with a Pen object. Thus, in order to draw anything, you must create at least two objects: a Graphics object and a Pen object. The Pen object stores attributes of the item to be drawn, such as line width and color. The address of the Pen object is passed as one of the arguments to the drawing method. For example, one variation of the DrawRectangle method receives the address of a Pen object and four integers as shown in the following code, which draws a rectangle with a width of 100, a height of 50 and an upper-left corner of (20, 10).
myGraphics.DrawRectangle(&myPen, 20, 10, 100, 50);
Conclusion: We have successfully implemented paint brush using GDI.

Other Projects to Try:

  1. Computer graphics codes in C++ Language
  2. To create a window application (WinDIR app/ Drive Tree app.) using different GUI components and Direct view architecture.
  3. Creating SDI, MDI, Dialog Based Application
  4. Java Applet Tutorial for Beginners
  5. Create a Help file for an Application using Help Workshop

Filed Under: Software Lab Assignments

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy