Skip to content

Commit

Permalink
cleanup and fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-develop committed Nov 3, 2024
1 parent b4c7b5a commit c504903
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fbimg.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,22 @@ int main(int argc, char** argv)
exit(4);
}
// printf("The framebuffer device was mapped to memory successfully.\n");

/* open image */
if (argc < 2)
{
perror("Accepts one image as argument");
close(fbfd);
munmap(fbp, screensize);
printf("Please give an image as argument\n");
exit(6);
}

data = stbi_load(argv[1], &width, &height, &n, 4);
if (data == NULL)
{
perror("An error occured when reading the image.");
close(fbfd);
munmap(fbp, screensize);
printf("An error occured when reading the image\n");
exit(7);
}

Expand All @@ -98,7 +102,7 @@ int main(int argc, char** argv)
width = vinfo.xres;
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++ )
for (x = 0; x < width; x++)
{
x_for_loc = x + (vinfo.xres-width);
location = (x_for_loc+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
Expand Down

0 comments on commit c504903

Please sign in to comment.