1 /********************************************************************************
2 * *
3 * S U N R A S T E R I m a g e O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2004,2005 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: FXRASImage.cpp,v 1.5 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 "FXSettings.h"
36 #include "FXRegistry.h"
37 #include "FXApp.h"
38 #include "FXId.h"
39 #include "FXDrawable.h"
40 #include "FXImage.h"
41 #include "FXRASImage.h"
42
43
44
45 /*
46 Notes:
47 - Only free image if owned!
48 */
49
50 using namespace FX;
51
52 /*******************************************************************************/
53
54 namespace FX {
55
56
57 // Suggested file extension
58 const FXchar FXRASImage::fileExt[]="ras";
59
60
61 // Object implementation
62 FXIMPLEMENT(FXRASImage,FXImage,NULL,0)
63
64
65 // Initialize
FXRASImage(FXApp * a,const void * pix,FXuint opts,FXint w,FXint h)66 FXRASImage::FXRASImage(FXApp* a,const void *pix,FXuint opts,FXint w,FXint h):FXImage(a,NULL,opts,w,h){
67 if(pix){
68 FXMemoryStream ms;
69 ms.open(FXStreamLoad,(FXuchar*)pix);
70 loadPixels(ms);
71 ms.close();
72 }
73 }
74
75
76 // Save pixel data only
savePixels(FXStream & store) const77 FXbool FXRASImage::savePixels(FXStream& store) const {
78 if(fxsaveRAS(store,data,width,height)){
79 return TRUE;
80 }
81 return FALSE;
82 }
83
84
85 // Load pixel data only
loadPixels(FXStream & store)86 FXbool FXRASImage::loadPixels(FXStream& store){
87 FXColor *pixels; FXint w,h;
88 if(fxloadRAS(store,pixels,w,h)){
89 setData(pixels,IMAGE_OWNED,w,h);
90 return TRUE;
91 }
92 return FALSE;
93 }
94
95
96 // Clean up
~FXRASImage()97 FXRASImage::~FXRASImage(){
98 }
99
100 }
101