本文整理汇总了C++中LPSTREAM::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ LPSTREAM::SetSize方法的具体用法?C++ LPSTREAM::SetSize怎么用?C++ LPSTREAM::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPSTREAM
的用法示例。
在下文中一共展示了LPSTREAM::SetSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveAs
HRESULT STDMETHODCALLTYPE TinySmiley::SaveAs(LPSTREAM pStm)//默认保存第一帧到文件流
{
if (!pStm) return S_FALSE;
if (m_images.size() == 0) return S_FALSE;
BITMAP bitmap = { 0 };
if (!GetObject(m_images[0], sizeof(BITMAP), (LPSTR)&bitmap))
return S_FALSE;
BITMAPINFOHEADER bi = { 0 };
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bitmap.bmWidth;
bi.biHeight = bitmap.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = bitmap.bmBitsPixel;
bi.biCompression = BI_RGB;
DWORD size = bitmap.bmWidthBytes * bitmap.bmHeight;
BITMAPFILEHEADER bfh = { 0 };
bfh.bfType = 0x4d42;
bfh.bfOffBits = min(14, sizeof(BITMAPFILEHEADER)) + sizeof(BITMAPINFOHEADER) + bi.biClrUsed * sizeof(RGBQUAD);
bfh.bfSize = bfh.bfOffBits + bitmap.bmWidthBytes*bitmap.bmHeight;
ULARGE_INTEGER libSize;
libSize.LowPart = bfh.bfSize;
pStm->SetSize(libSize);
ULONG cbWritten = 0;
pStm->Write(&bfh, min(14, sizeof(BITMAPFILEHEADER)), &cbWritten);
pStm->Write(&bi, bi.biSize, &cbWritten);
pStm->Write(bitmap.bmBits, bitmap.bmWidthBytes*bitmap.bmHeight, &cbWritten);
return S_OK;
}
示例2: szInput
STDMETHODIMP CZ80Assembler::Assemble(VARIANT varInput, int *lpInt)
{
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, output_buf_size);
output_contents = (unsigned char *) GlobalLock(hGlobal);
if (V_VT(&varInput) == VT_BSTR)
{
mode = MODE_NORMAL | MODE_COMMANDLINE;
CW2CT szInput(V_BSTR(&varInput));
input_contents = strdup(szInput);
}
else
{
mode = MODE_NORMAL;
if (curr_input_file) {
free(curr_input_file);
}
curr_input_file = strdup(m_bstrInputFile);
if (output_filename) {
free(output_filename);
}
output_filename = strdup(m_bstrOutputFile);
}
*lpInt = run_assembly();
GlobalUnlock(hGlobal);
if (m_pStmOutput != NULL)
{
m_pStmOutput->Release();
}
LPSTREAM pStream = NULL;
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
ULARGE_INTEGER ul;
ul.QuadPart = out_ptr - output_contents;
pStream->SetSize(ul);
m_pStmOutput = pStream;
return S_OK;
}