Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. struct BMP
  6. {
  7. char Type[2]; //File type. Set to "BM".
  8. unsigned long Size; //Size in BYTES of the file.
  9. unsigned long Reserved; //Reserved. Set to zero.
  10. unsigned long OffSet; //Offset to the data.
  11. unsigned long headsize; //Size of rest of header. Set to 40.
  12. unsigned long Width; //Width of bitmap in pixels.
  13. unsigned long Height; // Height of bitmap in pixels.
  14. unsigned int Planes; //Number of Planes. Set to 1.
  15. unsigned int BitsPerPixel; //Number of Bits per pixels.
  16. unsigned long Compression; //Compression. Usually set to 0.
  17. unsigned long SizeImage; //Size in bytes of the bitmap.
  18. unsigned long XPixelsPreMeter; //Horizontal pixels per meter.
  19. unsigned long YPixelsPreMeter; //Vertical pixels per meter.
  20. unsigned long ColorsUsed; //Number of colors used.
  21. unsigned long ColorsImportant; //Number of "important" colors.
  22. };
  23. struct Pixel
  24. {
  25. unsigned char B;
  26. unsigned char G;
  27. unsigned char R;
  28.  
  29. };
  30. void readBMP(char *File_Name)
  31. {
  32. BMP a;
  33. FILE *p = fopen(File_Name, "rb");
  34. if (p == NULL)
  35. {
  36. printf("Can't open file!");
  37. return;
  38. }
  39. else
  40. fread(&a, sizeof(BMP), 1, p);
  41. if (a.Type[0]!='B'||a.Type[1]!='M')
  42. {
  43. printf("This is not a BMP file");
  44. }
  45. else
  46. {
  47. printf("This is a BMP file\n");
  48. printf("The size of this file is %lu bytes\n", a.Size);
  49. printf("The witdth of this image is %lu pixels\n", a.Width);
  50. printf("The height of this image is %lu pixels\n", a.Height);
  51. printf("The number of bits per pixels in this image is %u\n", a.BitsPerPixel);
  52. }
  53.  
  54. }
  55. void main()
  56. {
  57. char a[] = "test.bmp";
  58. readBMP(a);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement