2 * FreeRDP: A Remote Desktop Protocol Client
3 * Bitmap File Format Utils
5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <freerdp/types.h>
25 #include <freerdp/utils/bitmap.h>
55 void freerdp_bitmap_write(char* filename, void* data, int width, int height, int bpp)
59 bmpfile_header header;
60 BITMAPINFOHEADER info_header;
62 fp = fopen(filename, "w+b");
66 printf("failed to open file %s\n", filename);
77 sizeof(bmpfile_magic) +
78 sizeof(bmpfile_header) +
79 sizeof(BITMAPINFOHEADER);
81 info_header.bmp_bytesz = width * height * (bpp / 8);
85 info_header.bmp_bytesz;
87 info_header.width = width;
88 info_header.height = (-1) * height;
89 info_header.nplanes = 1;
90 info_header.bitspp = bpp;
91 info_header.compress_type = 0;
92 info_header.hres = width;
93 info_header.vres = height;
94 info_header.ncolors = 0;
95 info_header.nimpcolors = 0;
96 info_header.header_sz = sizeof(BITMAPINFOHEADER);
98 fwrite((void*) &magic, sizeof(bmpfile_magic), 1, fp);
99 fwrite((void*) &header, sizeof(bmpfile_header), 1, fp);
100 fwrite((void*) &info_header, sizeof(BITMAPINFOHEADER), 1, fp);
101 fwrite((void*) data, info_header.bmp_bytesz, 1, fp);