Главная » Статьи » Информация

ПРОВЕРКА BMP ИЗОБРАЖЕНИЯ C++
#include "stdafx.h" 
#include <iostream> 
#include <conio.h> 
#include <stdio.h> 
#include <windows.h> 
using namespace std; 
   
#pragma pack(1)  

   
typedef struct { 
         WORD bfType; 
         DWORD bfSize; 
         WORD bfReserved_1, bfReserved_2; 
         DWORD bfOffBits;                    
}BitMapFileHeader; 
   
typedef struct { 
     DWORD biSize; 
     LONG biWidth; 
     LONG biHeight; 
     WORD biPlanes; 
     WORD biBitCount;  
     DWORD biCompression; 
     DWORD biSizeImage; 
     LONG biXPelsPerMeter; 
     LONG biYPelsPerMeter; 
     DWORD biClrUsed; 
     DWORD biClrImportant; 
}BitMapInfoHeader; 
   
int main(){ 
   
         BitMapFileHeader file_header;  
         BitMapInfoHeader info_header; 
   
         FILE *f1; 
   f1 = fopen ("D:\\visual\\img.bmp", "rb"); 
    if( f1 == 0) { 
     cout << "File ne naiden\n"; return 1; }  
   
   char check[2]; 
   check[0] = fgetc(f1); 
   check[1] = fgetc(f1); 
   if( check[0] == 'B' && check[1] == 'M' ) cout << "FILE BMP" << endl; else return 1; 

   fseek(f1, 0, 0); 
         fread(&file_header, sizeof(file_header),1 ,f1); 
    
         cout<< "SIZE FILE - " << file_header.bfSize << "bait" << endl; 
         fread(&info_header, sizeof(info_header), 1, f1); 

         cout << "Shirina izobrageniya - " << info_header.biWidth << "px" << endl 
     << "Vysota izobrageniya - " << info_header.biHeight << "px" << endl 
                 << "Glubina cveta - " << info_header.biBitCount << "bit" << endl 
                 << "Razmer izobtrageniya - " << info_header.biSizeImage << "bait" << endl; 

   fclose(f1); 
         return 0; 
}
Категория: Информация | Добавил: Пользователь (02.07.2013)
Просмотров: 492 | Рейтинг: 0.0/0
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Все материалы на сайте выложены с целью ознакомления!