Graphics Programming using Allegro

Practice Test

Double Buffering, Painting a Frame with Color

Published:  September 9, 2008
By Richard G. Baldwin

File: Allegro00135PracticeTest


Questions

1.  True or False:  The use of off-screen bitmap buffers can often improve the speed of a program.

Answer and Explanation

2.  True or False:  Off-screen bitmap buffers are normally used to conserve memory and have little impact on the speed of a program.

Answer and Explanation

3.  True or False:  A common practice is to draw on an off-screen bitmap buffer in memory, which can be done at high speed.  Then a function named blit is called to copy the image from the buffer to the screen very quickly.

Answer and Explanation

4.  True or False:  A common practice is to draw on an off-screen bitmap buffer in memory, which can be done at high speed.  Then a function named screenCopy is called to copy the image from the buffer to the screen very quickly.

Answer and Explanation

5.  True or False:  The code shown below can be used to create an off-screen bitmap buffer.

  BITMAP *buffer = NULL;

  buffer = create_bitmap(256,256);

Answer and Explanation

6.  True or False:  The code shown below can be used to create an off-screen bitmap buffer.

  BITMAP buffer = NULL;

  buffer = create_bitmap(256,256);

Answer and Explanation

7.  True or False:  When you create a bitmap image buffer, the image memory will be cleared automatically, with the integer value for the color black being automatically set into every pixel in the image buffer.

Answer and Explanation

8.  True or False:  When you create a bitmap image buffer, the image memory will not be cleared, so it will probably contain garbage: you should clear the bitmap before using it.

Answer and Explanation

9.  True or False:  The putpixel function cannot be used to set pixel colors in an off-screen bitmap buffer.

Answer and Explanation

10.  True or False:  The putpixel function can be used to set pixel colors in an off-screen bitmap buffer.

Answer and Explanation

11.  True or False:  The code shown below can be used to set the colors in a 255x255 block of pixels in an off-screen bitmap memory buffer, provided that the variable named buffer contains a pointer to the memory buffer.

  for(int row = 0;row < 255;row++){
    for(int column = 0;column < 255;column++){
      putpixel(buffer,column,row,makecol(column,row,128));
    }//end loop row
  }//end loop on column

Answer and Explanation

12.  True or False:  The code shown below is the typical way to set the colors in a 255x255 block of pixels in an off-screen bitmap memory buffer, provided that the variable named buffer contains a pointer to the memory buffer.

  for(int row = 0;row < 255;row++){
    for(int column = 0;column < 255;column++){
      setPixel(buffer,column,row,makecol(column,row,128));
    }//end loop row
  }//end loop on column

Answer and Explanation

13.  True or False:  By calling the blit function, a rectangular portion of a source bitmap can be copied to an arbitrary location in a destination bitmap and both bitmaps can be stored in off-screen memory buffers.

Answer and Explanation

14.  True or False:  By calling the blit function, a rectangular portion of a source bitmap can be copied to an arbitrary location in a destination bitmap with the restriction that one of the bitmaps must be the screen.

Answer and Explanation

15.  True or False:  In virtually all cases, producing an off-screen image and calling the blit function to copy the image onto the screen will be faster than constructing the image directly on the screen one pixel at a time.

Answer and Explanation



Copyright 2008, Richard G. Baldwin.  Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java, C#, and XML. In addition to the many platform and/or language independent benefits of Java and C# applications, he believes that a combination of Java, C#, and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects and he frequently provides onsite training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Programming Tutorials, which have gained a worldwide following among experienced and aspiring programmers. He has also published articles in JavaPro magazine.

In addition to his programming expertise, Richard has many years of practical experience in Digital Signal Processing (DSP).  His first job after he earned his Bachelor's degree was doing DSP in the Seismic Research Department of Texas Instruments.  (TI is still a world leader in DSP.)  In the following years, he applied his programming and DSP expertise to other interesting areas including sonar and underwater acoustics.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com

 


Answers and Explanations


Answer 15

True

Explanation 15

Back to Question 15


Answer 14

False - the restriction is not true

Explanation 14

Back to Question 14


Answer 13

True

Explanation 13

Back to Question 13


Answer 12

False - should  call putpixel, not setPixel

Explanation 12

Back to Question 12


Answer 11

True

Explanation 11

Back to Question 11


Answer 10

True

Explanation 10

Back to Question 10


Answer 9

False - the putpixel function can be used for that purpose.

Explanation 9

Back to Question 9


Answer 8

True

Explanation 8

Back to Question 8


Answer 7

False - not automatically cleared

Explanation 7

Back to Question 7


Answer 6

False - the variable named buffer must be a pointer varible.

Explanation 6

Back to Question 6


Answer 5

True

Explanation 5

Back to Question 5


Answer 4

False - blit, not screenCopy

Explanation 4

Back to Question 4


Answer 3

True

Explanation 3

Back to Question 3


 

Answer 2

False

Explanation 2

Back to Question 2


Answer 1

True

Explanation 1

Back to Question 1


Copyright 2008, Richard G. Baldwin.  Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java, C#, and XML. In addition to the many platform and/or language independent benefits of Java and C# applications, he believes that a combination of Java, C#, and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects and he frequently provides onsite training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Programming Tutorials, which have gained a worldwide following among experienced and aspiring programmers. He has also published articles in JavaPro magazine.

In addition to his programming expertise, Richard has many years of practical experience in Digital Signal Processing (DSP).  His first job after he earned his Bachelor's degree was doing DSP in the Seismic Research Department of Texas Instruments.  (TI is still a world leader in DSP.)  In the following years, he applied his programming and DSP expertise to other interesting areas including sonar and underwater acoustics.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com

 

-end-