FireBirdLib - Topfield TMS PVR TAP Programming Library
SaveBitmap.c
Go to the documentation of this file.
1#include <fcntl.h>
2#include <unistd.h>
3#include "FBLib_av.h"
4#include "libFireBird.h"
5
6bool SaveBitmap(char *FileName, int width, int height, byte* pBuffer)
7{
9
10 dword rowlength;
11 char AbsFilename[FBLIB_DIR_SIZE];
12 int FileHandle;
13
14 if(!pBuffer ||!FileName || !*FileName)
15 {
16 TRACEEXIT();
17 return FALSE;
18 }
19
20 ConvertPathType(FileName, AbsFilename, PF_FullLinuxPath);
21
22 FileHandle = open(AbsFilename, O_WRONLY | O_CREAT | O_TRUNC);
23 if(FileHandle == -1)
24 {
25 TRACEEXIT();
26 return FALSE;
27 }
28
29 // Write Header
30 BMP_WriteHeader(FileHandle, width, height);
31
32 // write bitmap data
33 // according to spec.: the rowlength must be a multiple of 4 bytes, if necessary fill up with zero-bytes
34 rowlength = (width*3%4==0) ? width*3 : ((width*3/4)+1)*4;
35 write(FileHandle, pBuffer, rowlength * height);
36 close(FileHandle);
37
38 TRACEEXIT();
39 return TRUE;
40}
void BMP_WriteHeader(int FileHandle, int width, int height)
void ConvertPathType(const char *Source, char *Dest, tPathFormat DestFormat)
bool SaveBitmap(char *FileName, int width, int height, byte *pBuffer)
Definition: SaveBitmap.c:6
#define FBLIB_DIR_SIZE
Definition: libFireBird.h:1871
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
@ PF_FullLinuxPath
Definition: libFireBird.h:1926