Cirrus Logic CS485 Dokumentacja Strona 105

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 319
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 104
Image Creation and Access
4-51
4
The dimensions of the converted IplImage should be greater than or
equal to that of the DIB image. When the converted image is larger
than the DIB image, the origins of
IplImage and the DIB image are
made coincident for the purposes of copying.
When converting a DIB RGBA image, the destination
IplImage
should also contain an alpha channel.
Example 4-9 Converting a DIB Image Into an IplImage
int example48( void ) {
BITMAPINFO *dib; // pointer to bitmap
RGBQUAD *rgb; // pointer to bitmap colors
unsigned char *data; // pointer to bitmap data
BITMAPINFOHEADER *dibh; // header beginning
IplImage *img = NULL;
int i;
__try {
int size = HEIGHT * ((WIDTH+3) & ~3);
// allocate memory for bitmap
dib = malloc(sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD)*256 + size );
if( NULL == dib ) return 0;
// define corresponedt pointers
dibh = (BITMAPINFOHEADER*)dib;
rgb=(RGBQUAD*)((char*)dib + sizeof(BITMAPINFOHEADER));
data = (unsigned char*)((char*)rgb +
sizeof(RGBQUAD)*256);
// define bitmap
dibh->biSize = sizeof(BITMAPINFOHEADER);
dibh->biWidth = WIDTH;
dibh->biHeight = HEIGHT;
dibh->biPlanes = 1;
dibh->biBitCount = 8;
continued
Przeglądanie stron 104
1 2 ... 100 101 102 103 104 105 106 107 108 109 110 ... 318 319

Komentarze do niniejszej Instrukcji

Brak uwag