Simple Operating System
pic.c
Go to the documentation of this file.
1 
6 #include <io.h>
7 #include <file.h>
8 #include <conio.h>
9 #include <graphics.h>
10 
11 __start int main() {
12  Byte name = 0x80;//name as parameter
13  setVideoMode(ColorMode);
14  puts("PIC\n");
15  unsigned int image_width = 0x20;
16  unsigned int image_height = 0x20;
17  Color image_bmp[1024];
18  Position pos = {100, 50};
19 
20  FILE *file;
21  file = open(name, "");
22  if(file == NULL) {
23  puts("ERROR file cannot be opened\n");
24  setVideoMode(TextMode);
25  return 404;
26  }
27  puts(name);
28 
29  if(read(image_bmp, 1024, file) != 1024) {
30  puts("ERROR");
31  setVideoMode(TextMode);
32  return 403;
33  }
34  draw(pos, image_bmp, image_width, image_height);
35  getc();
36  setVideoMode(TextMode);
37  return 0;
38 }
Console input output control.
void setVideoMode(Mode mode)
Set the video mode of screen.
Definition: conio.h:41
File IO.
FILE * open(int filename, int mode)
Open file.
Definition: file.h:33
int read(int buf, size_t size, FILE *stream)
Read from file.
Definition: file.h:53
Draw pixels in graphics mode.
void draw(Position begin, Color *data, size_t width, size_t height)
Draw picture from raw pixel table.
Definition: graphics.h:43
Standard input output library.
Key getc(void)
Wait for key in buffer, get it and clear buffer.
Definition: io.h:83
void puts(const int string)
Put string.
Definition: io.h:42
__start void main()
Definition: kernel.c:131
Information about file.
Definition: file.h:20
Position on screen.
Definition: graphics.h:16
#define NULL
pointer to NULL
Definition: types.h:22
#define __start
Must be before main function of program to put this function as first in binary file.
Definition: types.h:35