public class BitmapFormat
{
- class_data char ** extensions;
+ class_data const char ** extensions;
- class_property char ** extensions
+ class_property const char ** extensions
{
get { return class_data(extensions); }
set { class_data(extensions) = value; } }
virtual bool ::Load(Bitmap bitmap, File f);
- virtual bool ::Save(Bitmap bitmap, char * fileName, void * options);
- virtual ColorAlpha * ::LoadPalette(char * fileName, char * type);
+ virtual bool ::Save(Bitmap bitmap, const char * fileName, void * options);
+ virtual ColorAlpha * ::LoadPalette(const char * fileName, const char * type);
};
-static char * typesToTry[] =
+static const char * typesToTry[] =
{
"gif", "jpg", "png", "bmp", "pcx", "memorybmp"
};
#define NUM_TYPES_TO_TRY ((int)(sizeof(typesToTry) / sizeof(char *)))
-static subclass(BitmapFormat) FindFormat(char * type)
+static subclass(BitmapFormat) FindFormat(const char * type)
{
subclass(BitmapFormat) format = null;
if(type)
OldLink link;
for(link = class(BitmapFormat).derivatives.first; link; link = link.next)
{
- char ** extensions;
+ const char ** extensions;
format = link.data;
extensions = format.extensions;
if(extensions)
return format;
}
-public ColorAlpha * LoadPalette(char * fileName, char * type)
+public ColorAlpha * LoadPalette(const char * fileName, const char * type)
{
char ext[MAX_EXTENSION];
- subclass(BitmapFormat) format;
+ subclass(BitmapFormat) format = null;
ColorAlpha * palette = null;
int typeToTry = -1;
Bitmap bitmap { };
if(!type)
- {
- type = GetExtension(fileName, ext);
- strlwr(type);
- }
+ type = strlwr(GetExtension(fileName, ext));
if(type)
format = FindFormat(type);
subclass(DisplayDriver) driver;
void * driverData;
bool keepData;
+ bool mipMaps;
public:
Surface GetSurface(int x, int y, Box clip)
{
- Surface result;
+ Surface result = null;
Surface surface { };
if(surface)
{
surface.driver = (driver != null) ? driver : ((subclass(DisplayDriver))class(LFBDisplayDriver));
surface.displaySystem = displaySystem;
surface.display = null; // For now... with render to textures, the texture should have a display...
+ //surface.alphaWrite = write;
if(surface.driver.GetBitmapSurface(displaySystem, surface, this, x, y, box))
{
{
if(driver)
return driver.ConvertBitmap(displaySystem, this, format, palette);
- return false;
+ return pixelFormat == format;
}
bool Copy(Bitmap source)
bool result = false;
if(this && displaySystem && (!driver || driver == class(LFBDisplayDriver)))
{
- if(displaySystem.driver.MakeDDBitmap(displaySystem, this, false))
+ if(displaySystem.driver.MakeDDBitmap(displaySystem, this, false, 0))
{
this.displaySystem = displaySystem;
driver = displaySystem ? displaySystem.driver : ((subclass(DisplayDriver))class(LFBDisplayDriver));
bool result = false;
if(this && displaySystem && (!driver || driver == class(LFBDisplayDriver)))
{
- if(displaySystem.driver.MakeDDBitmap(displaySystem, this, true))
+ if(displaySystem.driver.MakeDDBitmap(displaySystem, this, true, 0))
{
+ this.mipMaps = true;
this.displaySystem = displaySystem;
result = true;
}
}
// --- Bitmap loading ---
- bool LoadFromFile(File file, char * type, DisplaySystem displaySystem)
+ bool LoadFromFile(File file, const char * type, DisplaySystem displaySystem)
{
bool result = false;
if(file)
return result;
}
- bool Load(char * fileName, char * type, DisplaySystem displaySystem)
+ bool Load(const char * fileName, const char * type, DisplaySystem displaySystem)
{
bool result = false;
char ext[MAX_EXTENSION];
- subclass(BitmapFormat) format;
+ subclass(BitmapFormat) format = null;
int typeToTry = -1;
+ const char * guessedType = type;
if(!fileName) return false;
- if(!type)
- {
- type = GetExtension(fileName, ext);
- strlwr(type);
- }
+ if(!guessedType)
+ guessedType = strlwr(GetExtension(fileName, ext));
- if(type)
- format = FindFormat(type);
+ if(guessedType)
+ format = FindFormat(guessedType);
if(!format)
typeToTry = 0;
delete f;
}
}
- if(typeToTry == -1) break;
+ if(typeToTry == -1)
+ {
+ if(type) break;
+ typeToTry = 0;
+ }
}
if(!result)
return result;
}
- bool LoadT(char * fileName, char * type, DisplaySystem displaySystem)
+ bool LoadT(const char * fileName, const char * type, DisplaySystem displaySystem)
{
bool result = Load(fileName, type, null);
if(result)
#define TRESHOLD 384
- bool LoadGrayed(char * fileName, char * type, DisplaySystem displaySystem)
+ bool LoadGrayed(const char * fileName, const char * type, DisplaySystem displaySystem)
{
bool result = Load(fileName, type, null);
if(result)
return result;
}
- bool LoadMonochrome(char * fileName, char * type, DisplaySystem displaySystem)
+ bool LoadMonochrome(const char * fileName, const char * type, DisplaySystem displaySystem)
{
bool result = Load(fileName, type, null);
if(result)
Free();
pixelFormat = grayed.pixelFormat;
+ size = grayed.size;
+ sizeBytes = grayed.sizeBytes;
stride = grayed.stride;
picture = grayed.picture;
grayed.picture = null;
return result;
}
- bool LoadMipMaps(char * fileName, char * type, DisplaySystem displaySystem)
+ bool LoadMipMaps(const char * fileName, const char * type, DisplaySystem displaySystem)
{
bool result = Load(fileName, type, null);
if(result)
return result;
}
- bool LoadTMipMaps(char * fileName, char * type, DisplaySystem displaySystem)
+ bool LoadTMipMaps(const char * fileName, const char * type, DisplaySystem displaySystem)
{
bool result = Load(fileName, type, null);
if(result)
return result;
}
- bool Save(char * fileName, char * type, void * options)
+ bool Save(const char * fileName, const char * type, void * options)
{
char ext[MAX_EXTENSION];
- subclass(BitmapFormat) format;
+ subclass(BitmapFormat) format = null;
if(!type)
- {
- type = GetExtension(fileName, ext);
- strlwr(type);
- }
+ type = strlwr(GetExtension(fileName, ext));
if(type)
format = FindFormat(type);
return result;
}
- bool Allocate(char * driverName, int width, int height, int stride, PixelFormat format, bool allocatePalette)
+ bool Allocate(const char * driverName, int width, int height, int stride, PixelFormat format, bool allocatePalette)
{
bool result = false;
subclass(DisplayDriver) displayDriver = driverName ? GetDisplayDriver(driverName) : ((subclass(DisplayDriver))class(LFBDisplayDriver));
if(this && driver)
{
driver.FreeBitmap(displaySystem, this);
+ driverData = null;
+ driver = class(LFBDisplayDriver);
}
if(this && keepData)
delete picture;
this.palette = palette;
allocatePalette = true;
pixelFormat = pixelFormat8;
+ sizeBytes = stride * height;
newBitmap.picture = null;
}
return palette;
}
};
+
+public class CubeMap : Bitmap
+{
+public:
+ void Load(DisplaySystem displaySystem, const String * names, const String extension, bool oldStyle)
+ {
+ int i;
+ for(i = 0; i < 6; i++)
+ {
+ char location[MAX_LOCATION];
+ Bitmap face = i > 0 ? { } : this;
+ strcpy(location, names[i]);
+ if(extension)
+ ChangeExtension(location, extension, location);
+ if(face.Load(location, null, null))
+ {
+ face.driverData = driverData;
+ displaySystem.driver.MakeDDBitmap(displaySystem, face, true, (i + 1) | (oldStyle << 3));
+ }
+ if(i > 0)
+ {
+ face.driverData = 0;
+ delete face;
+ }
+ }
+ }
+};