本文整理汇总了C++中LVStreamRef::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ LVStreamRef::Write方法的具体用法?C++ LVStreamRef::Write怎么用?C++ LVStreamRef::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LVStreamRef
的用法示例。
在下文中一共展示了LVStreamRef::Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
virtual ~LVRtfPictDestination()
{
if (!_fmt || _buf.empty())
return;
// add Image BLOB
lString16 name(BLOB_NAME_PREFIX); // L"@blob#"
name << L"image";
name << lString16::itoa(m_parser.nextImageIndex());
name << (_fmt==rtf_img_jpeg ? L".jpg" : L".png");
m_callback->OnBlob(name, _buf.get(), _buf.length());
#if 0
{
LVStreamRef stream = LVOpenFileStream((lString16(L"/tmp/") + name).c_str(), LVOM_WRITE);
stream->Write(_buf.get(), _buf.length(), NULL);
}
#endif
m_callback->OnTagOpen(LXML_NS_NONE, L"img");
m_callback->OnAttribute(LXML_NS_NONE, L"src", name.c_str());
m_callback->OnTagClose(LXML_NS_NONE, L"img");
}
示例2: SaveBitmapToFile
void SaveBitmapToFile( const char * fname, LVGrayDrawBuf * bmp )
{
if (!bmp)
return;
LVStreamRef stream = LVOpenFileStream(fname, LVOM_WRITE);
if (!stream)
return;
int rowsize = ((bmp->GetWidth()+1)/2);
int img_size = rowsize * bmp->GetHeight();
int padding = rowsize - rowsize;
BITMAPFILEHEADER fh;
struct {
BITMAPINFOHEADER hdr;
RGBQUAD colors[16];
} bmi;
memset(&fh, 0, sizeof(fh));
memset(&bmi, 0, sizeof(bmi));
fh.bfType = 0x4D42;
fh.bfSize = sizeof(fh) + sizeof(bmi) + img_size;
fh.bfOffBits = sizeof(fh) + sizeof(bmi);
bmi.hdr.biSize = sizeof(bmi.hdr);
bmi.hdr.biWidth = bmp->GetWidth();
bmi.hdr.biHeight = bmp->GetHeight();
bmi.hdr.biPlanes = 1;
bmi.hdr.biBitCount = 4;
bmi.hdr.biCompression = 0;
bmi.hdr.biSizeImage = img_size;
bmi.hdr.biXPelsPerMeter = 0xEC4;
bmi.hdr.biYPelsPerMeter = 0xEC4;
bmi.hdr.biClrUsed = 16;
bmi.hdr.biClrImportant = 16;
static lUInt8 gray[8] = { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xAA, 0x55, 0x00 };
lUInt8 * pal = bmp->GetBitsPerPixel()==1?gray+0:gray+4;
for (int i=0; i<4; i++)
{
bmi.colors[i].rgbBlue = pal[i];
bmi.colors[i].rgbGreen = pal[i];
bmi.colors[i].rgbRed = pal[i];
}
stream->Write( &fh, sizeof(fh), NULL );
stream->Write( &bmi, sizeof(bmi), NULL );
static const lUInt8 dummy[3] = {0,0,0};
for (int y=0; y<bmp->GetHeight(); y++)
{
LVArray<lUInt8> row( (bmp->GetWidth()+1)/2, 0 );
for ( int x=0; x<bmp->GetWidth(); x++)
{
int cl = bmp->GetPixel(x, bmp->GetHeight()-1-y);
//int cl = (src[x/8] >> ((1-(x&3))*2)) & 3;
row[x/2] = row[x/2] | (cl << ((x&1)?0:4));
}
row[0] = 0x11;
row[1] = 0x11;
row[2] = 0x22;
row[3] = 0x22;
row[4] = 0x33;
row[5] = 0x33;
*stream << row;
if (padding)
stream->Write( dummy, padding, NULL );
}
}