13 Lecture
CS410
Midterm & Final Term Short Notes
Graphics Device Interface
Graphics Device Interface (GDI) is a Windows API that facilitates drawing graphics and text on the screen and printers. It provides functions for 2D drawing, font rendering, and image manipulation, enabling developers to create graphical user in
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
1. What does GDI stand for in computer graphics?
a) Graphics Design Interface
b) Graphics Display Interface
c) Graphical Device Interface
d) Graphical Display Interface
Solution: c) Graphical Device Interface
2. Which Windows API provides functions for 2D drawing and font rendering?
a) GDI
b) GUI
c) API
d) DirectX
Solution: a) GDI
3. Which GDI function is used to draw lines on the screen?
a) DrawLine()
b) LineTo()
c) DrawPath()
d) DrawSegment()
Solution: b) LineTo()
4. What is the purpose of the SelectObject function in GDI?
a) To select a font for drawing text.
b) To select a color for filling shapes.
c) To select a pen or brush for drawing operations.
d) To select a file for image loading.
Solution: c) To select a pen or brush for drawing operations.
5. Which GDI function is used to draw text on the screen?
a) DrawText()
b) TextOut()
c) WriteText()
d) PrintText()
Solution: b) TextOut()
6. Which GDI object is used to store graphical images?
a) Pen
b) Brush
c) Bitmap
d) Font
Solution: c) Bitmap
7. What is the purpose of the StretchBlt function in GDI?
a) To draw a filled rectangle.
b) To resize an image.
c) To draw an elliptical shape.
d) To draw text in bold format.
Solution: b) To resize an image.
8. Which GDI function is used to create a custom color brush?
a) CreateSolidBrush()
b) CreatePatternBrush()
c) CreateColorBrush()
d) CreateCustomBrush()
Solution: a) CreateSolidBrush()
9. How is transparency achieved in GDI?
a) By using the SetTransparent function.
b) By selecting a transparent color.
c) GDI does not support transparency.
d) By using the SetLayeredWindowAttributes function.
Solution: d) By using the SetLayeredWindowAttributes function.
10. Which GDI function is used to draw an arc?
a) DrawArc()
b) ArcTo()
c) Arc()
d) ArcSegment()
Solution: c) Arc()
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
1. What is Graphics Device Interface (GDI) in Windows API?
Answer: GDI is a Windows API that provides functions for drawing graphics and text on the screen and printers. It enables developers to create graphical user interfaces and graphics-rich applications.
2. How does GDI handle fonts in graphical applications?
Answer: GDI uses fonts to render text on the screen. Developers can select a font using the SelectObject function and then use the TextOut or DrawText function to draw text on the screen.
3. What is the purpose of the CreatePen function in GDI?
Answer: The CreatePen function is used to create a logical pen object with specified attributes, such as color, width, and style. This pen can be selected using the SelectObject function for drawing lines and curves.
4. How does GDI handle color in graphical applications?
Answer: GDI uses RGB (Red, Green, Blue) values to represent colors. Developers can create solid color brushes using the CreateSolidBrush function to fill shapes with a specific color.
5. Explain the role of the BitBlt function in GDI.
Answer: The BitBlt function is used for bit-block transfers, allowing efficient copying of image data between devices like screens and bitmaps. It enables fast image drawing and manipulation.
6. What are GDI paths, and how are they used?
Answer: GDI paths are sequences of lines and curves that define a shape. They are created using functions like BeginPath, LineTo, and CurveTo. Developers can then stroke or fill the path using appropriate GDI functions.
7. How does GDI support printing in Windows applications?
Answer: GDI provides functions to create printer device contexts and print graphical elements directly to printers. Developers can use similar GDI functions as used for screen drawing but target the printer device context.
8. What is the purpose of the SetPixel function in GDI?
Answer: The SetPixel function sets the color of a single pixel at a specified location on the screen or a bitmap. It is useful for low-level pixel manipulation tasks.
9. How does GDI handle transparency and blending?
Answer: GDI supports transparency and blending through the use of alpha blending functions. Developers can set the transparency level and combine images or colors with existing content.
10. Can GDI be used for 3D graphics and hardware-accelerated rendering?
Answer: No, GDI is primarily designed for 2D graphics and does not support hardware-accelerated rendering or complex 3D graphics. For advanced 3D rendering, developers typically use APIs like DirectX or OpenGL.