Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ch1.c
- Parameters: none
- Create a 12-zone test chart with the following stripe widths (in pixels) per zone:
- 10 8 9 11
- 6 4 5 7
- 14 12 13 16
- Compile with:
- cc -o ch1 ch1.c
- The 1800x1800-pixel output file, named "chart1.gray", should then be converted using
- ImageMagick's "convert" command-line utility from the ".gray" bytestream format to
- a more standard image format like bmp:
- convert -size 1800x1800 -depth 8 chart1.gray chart1.bmp
- ImageMagick can be downloaded from: http://www.imagemagick.org/
- */
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdlib.h>
- int main() {
- unsigned char
- *buf, *ptr, *ptr2;
- int i, j, fd;
- //ptr2 = ptr = buf = calloc( 648 * 600, 1 );
- buf = calloc( 1800 * 1800, 1 );
- ptr2 = buf + 1800 * 800;
- ptr = ptr2 + 260;
- // 6
- for( i = 0; i < 13; i++ ) {
- for( j = 0; j < 6; j++ )
- *ptr++ = 255;
- ptr += 6;
- }
- for( j = 0; j < 6; j++ )
- *ptr++ = 255;
- // 4
- for( i = 0; i < 20; i++ ) {
- ptr += 4;
- for( j = 0; j < 4; j++ )
- *ptr++ = 255;
- }
- // 5
- for( i = 0; i < 16; i++ ) {
- ptr += 5;
- for( j = 0; j < 5; j++ )
- *ptr++ = 255;
- }
- // 7
- for( i = 0; i < 11; i++ ) {
- ptr += 7;
- for( j = 0; j < 7; j++ )
- *ptr++ = 255;
- }
- ptr = ptr2 + 1800;
- for( i = 0; i < 199; i++ ) {
- for( j = 0; j < 1800; j++ )
- *ptr++ = *ptr2++;
- }
- ptr2 = buf + 1800 * 600;
- ptr = ptr2 + 260;
- // 10
- for( i = 0; i < 8; i++ ) {
- for( j = 0; j < 10; j++ )
- *ptr++ = 255;
- ptr += 10;
- }
- // 8
- for( i = 0; i < 10; i++ ) {
- for( j = 0; j < 8; j++ )
- *ptr++ = 255;
- ptr += 8;
- }
- // 9
- for( i = 0; i < 9; i++ ) {
- for( j = 0; j < 9; j++ )
- *ptr++ = 255;
- ptr += 9;
- }
- // 11
- for( i = 0; i < 7; i++ ) {
- for( j = 0; j < 11; j++ )
- *ptr++ = 255;
- ptr += 11;
- }
- for( j = 0; j < 11; j++ )
- *ptr++ = 255;
- ptr = ptr2 + 1800;
- for( i = 0; i < 199; i++ ) {
- for( j = 0; j < 1800; j++ )
- *ptr++ = *ptr2++;
- }
- ptr2 = buf + 1800 * 1000;
- ptr = ptr2 + 260;
- // 14
- for( i = 0; i < 5; i++ ) {
- for( j = 0; j < 14; j++ )
- *ptr++ = 255;
- ptr += 14;
- }
- for( j = 0; j < 14; j++ )
- *ptr++ = 255;
- // 12
- for( i = 0; i < 7; i++ ) {
- ptr += 12;
- for( j = 0; j < 12; j++ )
- *ptr++ = 255;
- }
- // 13
- for( i = 0; i < 6; i++ ) {
- ptr += 13;
- for( j = 0; j < 13; j++ )
- *ptr++ = 255;
- }
- // 16
- for( i = 0; i < 5; i++ ) {
- ptr += 16;
- for( j = 0; j < 16; j++ )
- *ptr++ = 255;
- }
- ptr = ptr2 + 1800;
- for( i = 0; i < 199; i++ ) {
- for( j = 0; j < 1800; j++ )
- *ptr++ = *ptr2++;
- }
- fd = open( "chart1.gray", O_WRONLY | O_CREAT | O_TRUNC, 0600 );
- write( fd, buf, 1800 * 1800 );
- close( fd );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement