C language Function Daquan (i start)

Source: Internet
Author: User
Tags error code int size printf

Function Name: imagesize

Function: Returns the number of bytes required to hold the bit image

Usage: unsigned far imagesize (int left, int. top, int right, int bottom);

program Example:

#include
#include
#include
#include
#define ARROW_SIZE 10
void Draw_arrow (int x, int y);
int main (void)
{
* Request Autodetection * *
int gdriver = detect, Gmode, errorcode;
void *arrow;
int x, y, Maxx;
unsigned int size;
/* Initialize graphics and local variables * *
Initgraph (&gdriver, &gmode, "");
/* Read result of initialization * *
ErrorCode = Graphresult ();
if (errorcode!= grOk)/* An error occurred * *
{
printf ("Graphics Error:%s\n", Grapherrormsg (ErrorCode));
printf ("Press any key to halt:");
Getch ();
Exit (1); /* Terminate with an error code * *
}
Maxx = Getmaxx ();
x = 0;
y = Getmaxy ()/2;
/* Draw the image to be grabbed * *
Draw_arrow (x, y);
/* Calculate the size of the image * *
Size = ImageSize (x, Y-arrow_size, x+ (4*arrow_size), y+arrow_size);
/* Allocate memory to hold the image * *
Arrow = malloc (size);
/* Grab the image * *
GetImage (x, Y-arrow_size, x+ (4*arrow_size), y+arrow_size, ARROW);
/* Repeat until a key is pressed * *
while (!kbhit ())
{
/* Erase old image * *
Putimage (x, Y-arrow_size, ARROW, xor_put);
x + + arrow_size;
if (x >= Maxx)
x = 0;
/* Plot New image * *
Putimage (x, Y-arrow_size, ARROW, xor_put);
}
/* Clean up/*
Free (arrow);
Closegraph ();
return 0;
}
void Draw_arrow (int x, int y)
{
/* Draw an arrow on the screen * *
MoveTo (x, y);
Linerel (4*arrow_size, 0);
Linerel ( -2*arrow_size, -1*arrow_size);
Linerel (0, 2*arrow_size);
Linerel (2*arrow_size, -1*arrow_size);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.