本文整理汇总了C++中FXStream::save方法的典型用法代码示例。如果您正苦于以下问题:C++ FXStream::save方法的具体用法?C++ FXStream::save怎么用?C++ FXStream::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FXStream
的用法示例。
在下文中一共展示了FXStream::save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fxsaveRGB
// Save a bmp file to a stream
bool fxsaveRGB(FXStream& store,const FXColor *data,FXint width,FXint height){
const FXushort dimension=3;
const FXushort nchannels=3;
const FXushort magic=474;
const FXuint maxpix=255;
const FXuint minpix=0;
const FXuint dummy=0;
const FXuchar storage=0;
const FXuchar bpc=1;
FXuchar temp[4096],swap;
FXushort w=width;
FXushort h=height;
FXint i,j,c;
// Must make sense
if(data && 0<width && 0<height){
// Remember swap state
swap=store.swapBytes();
store.setBigEndian(TRUE);
// Save header
store << magic; // MAGIC (2)
store << storage; // STORAGE (1)
store << bpc; // BPC (1)
store << dimension; // DIMENSION (2)
store << w; // XSIZE (2)
store << h; // YSIZE (2)
store << nchannels; // ZSIZE (2)
store << minpix; // PIXMIN (4)
store << maxpix; // PIXMAX (4)
store << dummy; // DUMMY (4)
memset(temp,0,80); // Clean it
memcpy(temp,"IRIS RGB",8); // Write name
store.save(temp,80); // IMAGENAME (80)
store << dummy; // COLORMAP (4)
memset(temp,0,404); // Clean it
store.save(temp,404); // DUMMY (404)
// Write pixels
for(c=0; c<3; c++){
for(j=height-1; j>=0; j--){
for(i=0; i<width; i++) temp[i]=((FXuchar*)(data+j*width+i))[c];
store.save(temp,width);
}
}
// Reset swap status
store.swapBytes(swap);
return true;
}
return false;
}
示例2: save
// save object to stream
void FXBaseObject::save(FXStream& store) const {
FXObject::save(store);
store << app;
store << target;
store << message;
store << flags;
store << options;
store << datalen;
store.save((FXuchar*)data, (unsigned long)datalen);
}
示例3: fxsaveXPM
// Save image to a stream
FXbool fxsaveXPM(FXStream& store,const FXColor *data,FXint width,FXint height,FXbool fast){
const FXchar printable[]=" [email protected]#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";
const FXchar quote='"';
const FXchar comma=',';
const FXchar newline='\n';
FXColor colormap[256];
FXint numpixels=width*height;
FXint ncolors,cpp,len,i,j,c1,c2;
FXchar buffer[200];
FXColor color;
FXuchar *pixels,*ptr,pix;
// Must make sense
if(!data || width<=0 || height<=0) return false;
// Allocate temp buffer for pixels
if(!allocElms(pixels,numpixels)) return false;
// First, try EZ quantization, because it is exact; a previously
// loaded XPM will be re-saved with exactly the same colors.
if(!fxezquantize(pixels,data,colormap,ncolors,width,height,256)){
if(fast){
fxfsquantize(pixels,data,colormap,ncolors,width,height,256);
}
else{
fxwuquantize(pixels,data,colormap,ncolors,width,height,256);
}
}
FXASSERT(ncolors<=256);
// How many characters needed to represent one pixel, characters per line
cpp=(ncolors>MAXPRINTABLE)?2:1;
// Save header
store.save("/* XPM */\nstatic char * image[] = {\n",36);
// Save values
len=__snprintf(buffer,sizeof(buffer),"\"%d %d %d %d\",\n",width,height,ncolors,cpp);
store.save(buffer,len);
// Save the colors
for(i=0; i<ncolors; i++){
color=colormap[i];
c1=printable[i%MAXPRINTABLE];
c2=printable[i/MAXPRINTABLE];
if(FXALPHAVAL(color)){
len=__snprintf(buffer,sizeof(buffer),"\"%c%c c #%02x%02x%02x\",\n",c1,c2,FXREDVAL(color),FXGREENVAL(color),FXBLUEVAL(color));
store.save(buffer,len);
}
else{
len=__snprintf(buffer,sizeof(buffer),"\"%c%c c None\",\n",c1,c2);
store.save(buffer,len);
}
}
// Save the image
ptr=pixels;
for(i=0; i<height; i++){
store << quote;
for(j=0; j<width; j++){
pix=*ptr++;
if(cpp==1){
store << printable[pix];
}
else{
store << printable[pix%MAXPRINTABLE];
store << printable[pix/MAXPRINTABLE];
}
}
store << quote;
if(i<height-1){ store << comma; store << newline; }
}
store.save("};\n",3);
freeElms(pixels);
return true;
}