/home/jonas/tidevel/adt/Advanced Dialogs/source/Bitmap.c

00001 /*
00002         Advanved Dialogs v1.05
00003         Copyright (C) 2005-2007 Jonas Gehring
00004 
00005         Advanced Dialogs is free software; you can redistribute it and/or modify
00006         it under the terms of the GNU Lesser General Public License as published by
00007         the Free Software Foundation; either version 2 of the License, or
00008         (at your option) any later version.
00009 
00010         Advanced Dialogs is distributed in the hope that it will be useful,
00011         but WITHOUT ANY WARRANTY; without even the implied warranty of
00012         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013         GNU Lesser General Public License for more details.
00014 
00015         You should have received a copy of the GNU Lesser General Public License
00016         along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 // C Source File
00021 // Created 17.01.2006; 06:44:40
00022 
00023 
00024 #include <gray.h>
00025 
00026 #include "AdvDialogs.h"                                                 // This should be obvious ;)
00027 
00028 
00029 // Frees a Bitmap
00030 void FreeBitmap(ADVBITMAP *bitmap)
00031 {
00032         free(bitmap->data);
00033         free(bitmap);
00034 }
00035 
00036 
00037 // Creates a new Bitmap
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         // Allocate space
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 // Draws a Bitmap
00067 void DrawBitmap(ADVDIALOG *dialog, ADVBITMAP *bitmap)
00068 {
00069         // Draw Light Plane contents
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         // Draw Dark Plane contents
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 

Generated on Thu Oct 4 19:42:03 2007 for Advanced Dialogs by  doxygen 1.5.1