1 /********************************************************************************
2 *                                                                               *
3 *                          T I F F  I c o n   O b j e c t                       *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2001,2005 Eric Gillet.   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: FXTIFIcon.cpp,v 1.24 2005/01/16 16:06:07 fox Exp $                       *
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 "FXRegistry.h"
36 #include "FXApp.h"
37 #include "FXTIFIcon.h"
38 
39 
40 /*
41   Notes:
42   - FXTIFIcon has an alpha channel.
43 */
44 
45 using namespace FX;
46 
47 /*******************************************************************************/
48 
49 namespace FX {
50 
51 
52 // Suggested file extension
53 const FXchar FXTIFIcon::fileExt[]="tif";
54 
55 
56 // Object implementation
57 FXIMPLEMENT(FXTIFIcon,FXIcon,NULL,0)
58 
59 
60 #ifdef HAVE_TIFF_H
61 const FXbool FXTIFIcon::supported=TRUE;
62 #else
63 const FXbool FXTIFIcon::supported=FALSE;
64 #endif
65 
66 
67 // Initialize
FXTIFIcon(FXApp * a,const void * pix,FXColor clr,FXuint opts,FXint w,FXint h)68 FXTIFIcon::FXTIFIcon(FXApp* a,const void *pix,FXColor clr,FXuint opts,FXint w,FXint h):FXIcon(a,NULL,clr,opts,w,h),codec(0){
69   if(pix){
70     FXMemoryStream ms;
71     ms.open(FXStreamLoad,(FXuchar*)pix);
72     loadPixels(ms);
73     ms.close();
74     }
75   }
76 
77 
78 // Save pixels only
savePixels(FXStream & store) const79 FXbool FXTIFIcon::savePixels(FXStream& store) const {
80   if(fxsaveTIF(store,data,width,height,codec)){
81     return TRUE;
82     }
83   return FALSE;
84   }
85 
86 
87 // Load pixels only
loadPixels(FXStream & store)88 FXbool FXTIFIcon::loadPixels(FXStream& store){
89   FXColor *pixels; FXint w,h;
90   if(fxloadTIF(store,pixels,w,h,codec)){
91     setData(pixels,IMAGE_OWNED,w,h);
92     if(options&IMAGE_ALPHAGUESS) transp=guesstransp();
93     return TRUE;
94     }
95   return FALSE;
96   }
97 
98 
99 // Clean up
~FXTIFIcon()100 FXTIFIcon::~FXTIFIcon(){
101   }
102 
103 }
104