1 /********************************************************************************
2 *                                                                               *
3 *                      I R I S   R G B   I c o n   O b j e c t                  *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2002,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (at your option) any later version.            *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXRGBIcon.cpp 3297 2015-12-14 20:30:04Z arthurcnorman $                       *
23 ********************************************************************************/
24 #include "xincs.h"
25 #include "fxver.h"
26 #include "fxdefs.h"
27 #include "FXHash.h"
28 #include "FXThread.h"
29 #include "FXStream.h"
30 #include "FXMemoryStream.h"
31 #include "FXString.h"
32 #include "FXSize.h"
33 #include "FXPoint.h"
34 #include "FXRectangle.h"
35 #include "FXObject.h"
36 #include "FXSettings.h"
37 #include "FXRegistry.h"
38 #include "FXApp.h"
39 #include "FXId.h"
40 #include "FXDrawable.h"
41 #include "FXImage.h"
42 #include "FXIcon.h"
43 #include "FXRGBIcon.h"
44 
45 
46 /*
47   Notes:
48 */
49 
50 using namespace FX;
51 
52 /*******************************************************************************/
53 
54 namespace FX {
55 
56 
57 // Suggested file extension
58 const FXchar FXRGBIcon::fileExt[]="rgb";
59 
60 
61 // Suggested mime type
62 const FXchar FXRGBIcon::mimeType[]="image/rgb";
63 
64 
65 // Object implementation
66 FXIMPLEMENT(FXRGBIcon,FXIcon,NULL,0)
67 
68 
69 // Initialize nicely
FXRGBIcon(FXApp * a,const void * pix,FXColor clr,FXuint opts,FXint w,FXint h)70 FXRGBIcon::FXRGBIcon(FXApp* a,const void *pix,FXColor clr,FXuint opts,FXint w,FXint h):FXIcon(a,NULL,clr,opts,w,h){
71   if(pix){
72     FXMemoryStream ms;
73     ms.open(FXStreamLoad,(FXuchar*)pix);
74     loadPixels(ms);
75     ms.close();
76     }
77   }
78 
79 
80 // Save object to stream
savePixels(FXStream & store) const81 bool FXRGBIcon::savePixels(FXStream& store) const {
82   if(fxsaveRGB(store,data,width,height)){
83     return true;
84     }
85   return false;
86   }
87 
88 
89 // Load object from stream
loadPixels(FXStream & store)90 bool FXRGBIcon::loadPixels(FXStream& store){
91   FXColor *pixels; FXint w,h;
92   if(fxloadRGB(store,pixels,w,h)){
93     setData(pixels,IMAGE_OWNED,w,h);
94     if(options&IMAGE_ALPHAGUESS) transp=guesstransp();
95     return true;
96     }
97   return false;
98   }
99 
100 
101 // Clean up
~FXRGBIcon()102 FXRGBIcon::~FXRGBIcon(){
103   }
104 
105 }
106