From Farshid Lashkari, "I've made some changes to the IVE loader which will add the capability
of saving image files inside the IVE file. Currently, only the raw image data is saved into the file. If your model uses jpg images as textures then this will cause your file size to increase. I've added an option that will embed the original image file into the IVE file. The IVE file will then attempt to read the image from memory. Since most image loaders support reading from memory, this shouldn't be a problem. To use this new feature the user must specify the option "includeImageFileInIVEFile" when converting to IVE. I tested this out on the "skydome.osg" model that comes with OSG. Using the old method, the IVE file size would be 785 KB, with the new method it is only 42 KB. Also, I've added the support for TextureRectangle's to the IVE reader/writer."
This commit is contained in:
@@ -33,24 +33,10 @@ void Texture1D::write(DataOutputStream* out){
|
||||
// Write image.
|
||||
|
||||
// Should we include images date in stream
|
||||
bool includeImg = out->getIncludeImageData();
|
||||
out->writeBool(includeImg);
|
||||
IncludeImageMode includeImg = out->getIncludeImageMode();
|
||||
out->writeChar(includeImg);
|
||||
|
||||
// Include image data in stream
|
||||
if(includeImg){
|
||||
out->writeBool(getImage()!=0);
|
||||
if(getImage())
|
||||
((ive::Image*)getImage())->write(out);
|
||||
}
|
||||
// Only include image name in stream
|
||||
else{
|
||||
if (getImage() && !(getImage()->getFileName().empty())){
|
||||
out->writeString(getImage()->getFileName());
|
||||
}
|
||||
else{
|
||||
out->writeString("");
|
||||
}
|
||||
}
|
||||
out->writeImage(includeImg,getImage());
|
||||
}
|
||||
|
||||
void Texture1D::read(DataInputStream* in){
|
||||
@@ -69,27 +55,11 @@ void Texture1D::read(DataInputStream* in){
|
||||
// Read image.
|
||||
|
||||
// Should we read image data from stream
|
||||
bool includeImg = in->readBool();
|
||||
IncludeImageMode includeImg = (IncludeImageMode)in->readChar();
|
||||
|
||||
// Read image data from stream
|
||||
if(includeImg)
|
||||
{
|
||||
if(in->readBool())
|
||||
{
|
||||
osg::Image* image = new osg::Image();
|
||||
((ive::Image*)image)->read(in);
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
// Only read image name from stream.
|
||||
else{
|
||||
std::string filename = in->readString();
|
||||
if(filename.compare("")!=0){
|
||||
osg::Image* image = in->readImage(filename);
|
||||
if (image){
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
osg::Image *image = in->readImage(includeImg);
|
||||
if(image) {
|
||||
setImage(image);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
Reference in New Issue
Block a user