00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <gray.h>
00025
00026 #include "AdvDialogs.h"
00027
00028
00029
00030 void FreeBitmap(ADVBITMAP *bitmap)
00031 {
00032 free(bitmap->data);
00033 free(bitmap);
00034 }
00035
00036
00037
00038 ADVBITMAP *AdvDlgBitmapNew(short width, short height, const unsigned char *lpdata, const unsigned char *dpdata)
00039 {
00040 ADVBITMAP *bitmap;
00041 short size = (height*width) >> 3;
00042
00043
00044 if ((bitmap = malloc(sizeof(ADVBITMAP))) == NULL)
00045 {
00046 return NULL;
00047 }
00048 if ((bitmap->data = malloc((BITMAP_HDR_SIZE + size)*2)) == NULL)
00049 {
00050 free(bitmap);
00051 return NULL;
00052 }
00053
00054 BITMAP *t = (BITMAP *)((char*)bitmap->data + BITMAP_HDR_SIZE + size);
00055
00056 t->NumRows = bitmap->data->NumRows = height;
00057 t->NumCols = bitmap->data->NumCols = width;
00058
00059 memcpy(bitmap->data->Data, lpdata, size);
00060 memcpy(t->Data, dpdata, size);
00061
00062 return bitmap;
00063 }
00064
00065
00066
00067 void DrawBitmap(ADVDIALOG *dialog, ADVBITMAP *bitmap)
00068 {
00069
00070 GraySetAMSPlane(LIGHT_PLANE);
00071 BitmapPut((dialog->left_x + bitmap->x), (dialog->top_y + bitmap->y),
00072 bitmap->data,
00073 &(SCR_RECT){{dialog->left_x, dialog->top_y, dialog->right_x, dialog->bottom_y}},
00074 A_REPLACE);
00075
00076
00077 GraySetAMSPlane(DARK_PLANE);
00078 BitmapPut((dialog->left_x + bitmap->x), (dialog->top_y + bitmap->y),
00079 (BITMAP *)((char*)bitmap->data + BITMAP_HDR_SIZE + ((bitmap->data->NumRows*bitmap->data->NumCols) >> 3)),
00080 &(SCR_RECT){{dialog->left_x, dialog->top_y, dialog->right_x, dialog->bottom_y}},
00081 A_REPLACE);
00082
00083 }
00084