24 #include <FXPNGImage.h>
25 #include <FXJPGImage.h>
28 #pragma warning(disable: 4244)
30 #include <FXTIFImage.h>
41 if (comparecase(ext,
"png") == 0) {
42 if (!FXPNGImage::supported) {
45 }
else if (comparecase(ext,
"jpg") == 0 || comparecase(ext,
"jpeg") == 0) {
46 if (!FXJPGImage::supported) {
49 }
else if (comparecase(ext,
"tif") == 0 || comparecase(ext,
"tiff") == 0) {
50 if (!FXTIFImage::supported) {
59 FXString ext = FXPath::extension(file.c_str());
61 FXImage* img =
nullptr;
62 if (comparecase(ext,
"gif") == 0) {
63 img =
new FXGIFImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
64 }
else if (comparecase(ext,
"bmp") == 0) {
65 img =
new FXBMPImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
66 }
else if (comparecase(ext,
"xpm") == 0) {
67 img =
new FXXPMImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
68 }
else if (comparecase(ext,
"pcx") == 0) {
69 img =
new FXPCXImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
70 }
else if (comparecase(ext,
"ico") == 0 || comparecase(ext,
"cur") == 0) {
71 img =
new FXICOImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
72 }
else if (comparecase(ext,
"tga") == 0) {
73 img =
new FXTGAImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
74 }
else if (comparecase(ext,
"rgb") == 0) {
75 img =
new FXRGBImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
76 }
else if (comparecase(ext,
"xbm") == 0) {
77 img =
new FXXBMImage(a,
nullptr,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
78 }
else if (comparecase(ext,
"png") == 0) {
79 img =
new FXPNGImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
80 }
else if (comparecase(ext,
"jpg") == 0 || comparecase(ext,
"jpeg") == 0) {
81 img =
new FXJPGImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
82 }
else if (comparecase(ext,
"tif") == 0 || comparecase(ext,
"tiff") == 0) {
83 img =
new FXTIFImage(a,
nullptr, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
89 if (img !=
nullptr && stream.open(file.c_str(), FXStreamLoad)) {
91 img->loadPixels(stream);
107 for (FXint exp = 30; exp >= 0; exp--) {
108 newHeight = 2 << exp;
109 if (newHeight <= maxSize && (image->getHeight() & newHeight)) {
113 if (2 * newHeight <= maxSize && (2 * newHeight - image->getHeight() < image->getHeight() - newHeight)) {
117 for (FXint exp = 30; exp >= 0; exp--) {
119 if (newWidth <= maxSize && (image->getWidth() & newWidth)) {
123 if (2 * newWidth <= maxSize && (2 * newWidth - image->getWidth() < image->getWidth() - newWidth)) {
126 if (newHeight == image->getHeight() && newWidth == image->getWidth()) {
129 image->scale(newWidth, newHeight);
138 int width,
int height, FXColor* data) {
139 FXString ext = FXPath::extension(file.c_str());
142 if (!stream.open(file.c_str(), FXStreamSave)) {
145 if (comparecase(ext,
"gif") == 0) {
146 return fxsaveGIF(stream, data, width, height,
false );
147 }
else if (comparecase(ext,
"bmp") == 0) {
148 return fxsaveBMP(stream, data, width, height);
149 }
else if (comparecase(ext,
"xpm") == 0) {
150 return fxsaveXPM(stream, data, width, height);
151 }
else if (comparecase(ext,
"pcx") == 0) {
152 return fxsavePCX(stream, data, width, height);
153 }
else if (comparecase(ext,
"ico") == 0 || comparecase(ext,
"cur") == 0) {
154 return fxsaveICO(stream, data, width, height);
155 }
else if (comparecase(ext,
"tga") == 0) {
156 return fxsaveTGA(stream, data, width, height);
157 }
else if (comparecase(ext,
"rgb") == 0) {
158 return fxsaveRGB(stream, data, width, height);
159 }
else if (comparecase(ext,
"xbm") == 0) {
160 return fxsaveXBM(stream, data, width, height);
161 }
else if (comparecase(ext,
"png") == 0) {
162 return fxsavePNG(stream, data, width, height);
163 }
else if (comparecase(ext,
"jpg") == 0 || comparecase(ext,
"jpeg") == 0) {
164 return fxsaveJPG(stream, data, width, height, 75);
165 }
else if (comparecase(ext,
"tif") == 0 || comparecase(ext,
"tiff") == 0) {
166 return fxsaveTIF(stream, data, width, height, 0);
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void checkSupported(FXString ext)
static FXImage * loadImage(FXApp *a, const std::string &file)
static FXbool scalePower2(FXImage *image, int maxSize=(2<< 29))
static FXbool saveImage(const std::string &file, int width, int height, FXColor *data)