FreeBASIC  0.91.0
gfx_image_info.c
Go to the documentation of this file.
1 /* function to get information about FB image buffers. */
2 
3 #include "fb_gfx.h"
4 
5 
6 FBCALL int fb_GfxImageInfo( void *img,
7  int *width, int *height,
8  int *bpp, int *pitch, void **imgdata,
9  int *size)
10 {
11  PUT_HEADER *header;
12  int bpp_, width_, height_, pitch_, headerSize_;
13 
14  header = (PUT_HEADER *)img;
15 
16  if (!header || header->type == 0)
17  {
18  *width = *height = *bpp = *pitch = *size = -1;
19  *imgdata = NULL;
21  }
22  else if (header->type == PUT_HEADER_NEW) {
23  bpp_ = header->bpp;
24  width_ = header->width;
25  height_ = header->height;
26  pitch_ = header->pitch;
27  headerSize_ = sizeof(PUT_HEADER);
28  }
29  else {
30  bpp_ = header->old.bpp;
31  width_ = header->old.width;
32  height_ = header->old.height;
33  pitch_ = width_ * bpp_;
34  headerSize_ = 4;
35  }
36 
37  *width = width_;
38  *height = height_;
39  *bpp = bpp_;
40  *pitch = pitch_;
41  *imgdata = img + headerSize_;
42  *size = headerSize_ + (pitch_ * height_);
43 
44  return fb_ErrorSetNum( FB_RTERROR_OK );
45 }