本文整理匯總了C++中GetBuffer函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetBuffer函數的具體用法?C++ GetBuffer怎麽用?C++ GetBuffer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetBuffer函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1:
Air::U1 Buffer11::Read( U32 uiOffset,U32 uiSize,void* pData )
{
DxContext* pContext = (DxContext*)(pDevice->GetContext());
ID3D11Resource* pResource = (ID3D11Resource*)GetBuffer();
D3D11_MAPPED_SUBRESOURCE res;
HRESULT hr = pContext->Map(pResource,0,D3D11_MAP_READ,0,&res);
if(SUCCEEDED(hr)){
U8* pDst = (U8*)res.pData;
memcpy(pData,&pDst[uiOffset],uiSize);
pContext->Unmap(pResource,0);
}
return true;
}
示例2: GetLength
// Delete - Deletes a segment of the string and resizes it
// Returns - Reference to the same string object
// pos - Position of the string segment to remove
// len - Number of characters to remove
CStringEx& CStringEx::Delete(int pos, int len)
{
int strLen = GetLength();
if( pos >= strLen)
return *this;
if(len < 0 ||len > strLen - pos)
len = strLen - pos;
LPTSTR str = GetBuffer( strLen );
memmove(str+pos, str+pos+len, sizeof(_T(' ')) *(strLen-pos));
ReleaseBuffer( strLen - len );
return *this;
}
示例3: dc
// TODO: this code require full information about editabel register in dialog
// TODO: to make editable all registers which is output
void RegRichTextCtrl::OnLeftDClick(wxMouseEvent& event)
{
wxClientDC dc(this);
PrepareDC(dc);
dc.SetFont(GetFont());
long position = 0;
GetBuffer().HitTest(dc, event.GetLogicalPosition(dc), position);
long linePos = GetBuffer().GetVisibleLineNumber(position, true, true);
wxString line = GetLineText(linePos);
const size_t szRegNames = 15;
for (size_t i = 0; i < szRegNames; ++i)
if (line.Find(RegistersName[i]) != wxNOT_FOUND)
{
wxString str = GetStringSelection();
bool bShowEditBox = true;
for (size_t k = 0; k < szRegNames; ++k)
{
if ( 0 == str.Cmp(RegistersName[k]) )
{
bShowEditBox = false;
break;
}
}
if (bShowEditBox)
{
EditRegister(RegistersName[i], str);
break;
}
}
}
示例4: ReadHeader
static ParseStatus ReadHeader(MemBuffer* const mem) {
const size_t min_size = RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE;
uint32_t riff_size;
// Basic file level validation.
if (MemDataSize(mem) < min_size) return PARSE_NEED_MORE_DATA;
if (memcmp(GetBuffer(mem), "RIFF", CHUNK_SIZE_BYTES) ||
memcmp(GetBuffer(mem) + CHUNK_HEADER_SIZE, "WEBP", CHUNK_SIZE_BYTES)) {
return PARSE_ERROR;
}
riff_size = GetLE32(GetBuffer(mem) + TAG_SIZE);
if (riff_size < CHUNK_HEADER_SIZE) return PARSE_ERROR;
if (riff_size > MAX_CHUNK_PAYLOAD) return PARSE_ERROR;
// There's no point in reading past the end of the RIFF chunk
mem->riff_end_ = riff_size + CHUNK_HEADER_SIZE;
if (mem->buf_size_ > mem->riff_end_) {
mem->buf_size_ = mem->end_ = mem->riff_end_;
}
Skip(mem, RIFF_HEADER_SIZE);
return PARSE_OK;
}
示例5: memcpy
size_t GarlicRoutingSession::CreateDeliveryStatusClove (uint8_t * buf, uint32_t msgID)
{
size_t size = 0;
if (m_Owner)
{
auto inboundTunnel = m_Owner->GetTunnelPool ()->GetNextInboundTunnel ();
if (inboundTunnel)
{
buf[size] = eGarlicDeliveryTypeTunnel << 5; // delivery instructions flag tunnel
size++;
// hash and tunnelID sequence is reversed for Garlic
memcpy (buf + size, inboundTunnel->GetNextIdentHash (), 32); // To Hash
size += 32;
htobe32buf (buf + size, inboundTunnel->GetNextTunnelID ()); // tunnelID
size += 4;
// create msg
auto msg = CreateDeliveryStatusMsg (msgID);
if (m_Owner)
{
//encrypt
uint8_t key[32], tag[32];
RAND_bytes (key, 32); // random session key
RAND_bytes (tag, 32); // random session tag
m_Owner->SubmitSessionKey (key, tag);
GarlicRoutingSession garlic (key, tag);
msg = garlic.WrapSingleMessage (msg);
}
memcpy (buf + size, msg->GetBuffer (), msg->GetLength ());
size += msg->GetLength ();
// fill clove
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 8000; // 8 sec
uint32_t cloveID;
RAND_bytes ((uint8_t *)&cloveID, 4);
htobe32buf (buf + size, cloveID); // CloveID
size += 4;
htobe64buf (buf + size, ts); // Expiration of clove
size += 8;
memset (buf + size, 0, 3); // certificate of clove
size += 3;
}
else
LogPrint (eLogError, "Garlic: No inbound tunnels in the pool for DeliveryStatus");
}
else
LogPrint (eLogWarning, "Garlic: Missing local LeaseSet");
return size;
}
示例6: RenderLine
void RenderLine(uint8 *pStart, float xOff, float vLineTop, float vLineBottom, int nCursor, int nSelStart, int nSelEnd, View *pcView, bool bSelected)
{
Color32_s sCursCol(40,40,40);
Color32_s sCursLineCol(255,235,186);
if( ! bSelected )
{
sCursCol = lighten_color(sCursCol);
sCursLineCol = lighten_color(sCursLineCol);
}
float vCharWidth = GetCharWidth();
float vCharHeight = GetCharHeight();
uint8 *pEnd = GetBuffer() + GetBufferLength();
static char zLine[(BYTES_PER_LINE) + 1];
for( int x = 0; x < BYTES_PER_LINE; x++ )
{
uint8 *p = pStart + x;
zLine[x] = p >= pEnd || *p < 32 || *p > 126?'.':*p;
}
Rect cRect(xOff + GetX() + 2, vLineTop, xOff + GetX() + GetWidth() - 2, vLineBottom);
pcView->SetFgColor(Color32_s(0,0,0));
if( nSelStart < 0 )
{
if( nCursor >= 0 )
pcView->FillRect(cRect, sCursLineCol);
pcView->DrawText(cRect, zLine);
if( nCursor >= 0 )
{
float vCursorX = cRect.left + (vCharWidth * nCursor);
pcView->SetFgColor(sCursCol);
pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom));
vCursorX++;
pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom));
}
}
else
{
IPoint cSel1((int)(nSelStart * vCharWidth), (int)vCharHeight);
IPoint cSel2((int)((nSelEnd * vCharWidth) + 1), (int)vCharHeight);
pcView->DrawSelectedText(cRect, zLine, cSel1, cSel2, SEL_CHAR);
}
}
示例7: TINYCLR_HEADER
HRESULT CLR_RT_HeapBlock_XmlReader::Read()
{
TINYCLR_HEADER();
CLR_RT_XmlState* state = GetState();
state->State.bufferStart = GetBuffer();
state->State.buffer = state->State.bufferStart + GetOffset();
state->State.bufferEnd = state->State.buffer + GetLength();
state->State.reader = this;
if(state->State.initFn)
{
state->State.initFn( state );
}
while(true)
{
TINYCLR_CHECK_HRESULT(state->State.stateFn( state ));
}
TINYCLR_CLEANUP();
if(hr == XML_E_NEED_MORE_DATA)
{
if(state->State.cleanUpFn)
{
state->State.cleanUpFn( state );
}
else
{
state->State.ShiftBuffer( state->State.buffer );
}
// if after buffer adjustment, there's no room for new data, then we know that
// we've exceeded one of the system constraints (either the length of name or
// attribute value is over buffer size)
if(state->State.bufferEnd - state->State.bufferStart == XmlBufferSize)
{
hr = XML_E_LIMIT_EXCEEDED;
}
}
SetOffset( state->State.buffer - state->State.bufferStart );
SetLength( state->State.bufferEnd - state->State.buffer );
TINYCLR_CLEANUP_END();
}
示例8: MOZ_ASSERT
bool
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize)
{
MOZ_ASSERT(IsValid());
MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This textureClient cannot use YCbCr data");
int bufSize
= ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat);
if (!Allocate(bufSize)) {
return false;
}
ImageDataSerializer serializer(GetBuffer());
serializer.InitializeBufferInfo(aSize, mFormat);
mSize = aSize;
return true;
}
示例9: set_structure_element
void Binarization::HMT(unsigned char *buffer_in, unsigned char *buffer_out, bool inverse) {
set_structure_element(mixture_structure_element_2_);
unsigned char *buffer = GetBuffer(BUFFER_INTERMEDIATE - 1);
Invert(buffer_in, buffer);
Erode(buffer, buffer, inverse);
set_structure_element(mixture_structure_element_1_);
Erode(buffer_in, buffer_out, inverse);
for(int i = 1; i < height_ - 1; i++)
for(int j = 1; j < width_ - 1; j++) {
buffer_out[(i * width_ + j) * 3 + 2] = inverse ? buffer_out[(i * width_ + j) * 3 + 2] | buffer[(i * width_ + j) * 3 + 2] : buffer_out[(i * width_ + j) * 3 + 2] & buffer[(i * width_ + j) * 3 + 2];
buffer_out[(i * width_ + j) * 3 + 1] = inverse ? buffer_out[(i * width_ + j) * 3 + 1] | buffer[(i * width_ + j) * 3 + 1] : buffer_out[(i * width_ + j) * 3 + 1] & buffer[(i * width_ + j) * 3 + 1];
buffer_out[(i * width_ + j) * 3 + 0] = inverse ? buffer_out[(i * width_ + j) * 3 + 0] | buffer[(i * width_ + j) * 3 + 0] : buffer_out[(i * width_ + j) * 3 + 0] & buffer[(i * width_ + j) * 3 + 0];
}
}
示例10: GetSize
bool
BufferTextureData::BorrowMappedData(MappedTextureData& aData)
{
if (GetFormat() == gfx::SurfaceFormat::YUV) {
return false;
}
gfx::IntSize size = GetSize();
aData.data = GetBuffer();
aData.size = size;
aData.format = GetFormat();
aData.stride = ImageDataSerializer::ComputeRGBStride(aData.format, size.width);
return true;
}
示例11: ASSERT
LPSTR IUrlDownloader::CreateCharCopy() const
{
ASSERT(GetStatus() == S_Success);
LPSTR ret = NULL;
if (GetStatus() == S_Success)
{
UINT bfLen = GetBufferSize();
if (bfLen > 0)
{
ret = new CHAR[bfLen + 1];
strncpy(ret, (LPCSTR)GetBuffer(), bfLen);
ret[bfLen] = 0;
}
}
return ret;
}
示例12: CameraEventData
/// ctor; parses event data
CameraEventData(prVoid* pEventData)
:m_uiEventCode(0)
{
BYTE* pbData = reinterpret_cast<BYTE*>(pEventData);
std::vector<BYTE>& vecBuffer = GetBuffer();
vecBuffer.assign(pbData, pbData + 12);// at least 12 bytes
// read length of event data
prUInt32 uiLength = ReadUint32();
vecBuffer.assign(pbData, pbData + uiLength);
unsigned int uiNumParams = (uiLength - 12) / 4;
Parse(uiNumParams);
}
示例13: ofs
void ImageProcessing::Output(const char *output, int buffer_num) {
std::ofstream ofs(output, std::ifstream::binary);
ofs.write((char *)head_, head_size_);
unsigned char *canvas = GetBuffer(buffer_num);
for(int i = 0; i < height_; i++)
for(int j = 0; j < width_; j++) {
image_[image_size_ / height_ * i + j * 3 + 2] = canvas[(i * width_ + j) * 3 + 2];
image_[image_size_ / height_ * i + j * 3 + 1] = canvas[(i * width_ + j) * 3 + 1];
image_[image_size_ / height_ * i + j * 3 + 0] = canvas[(i * width_ + j) * 3 + 0];
}
ofs.write((char *)image_, image_size_);
ofs.close();
}
示例14: GetLength
void CComplexBinary::Append (CDatum dDatum)
// Append
//
// Appends data
{
const CString &sNewData = dDatum;
if (sNewData.GetLength() == 0)
return;
// Compute the new length
int iOldLen = GetLength();
int iNewLen = iOldLen + sNewData.GetLength();
// Allocate a new buffer
char *pNewBuffer = new char [sizeof(DWORD) + iNewLen + 1];
char *pPos = pNewBuffer;
*(DWORD *)pPos = iNewLen;
pPos += sizeof(DWORD);
// Copy the original data
if (iOldLen)
{
utlMemCopy(m_pData, pPos, iOldLen);
pPos += iOldLen;
}
// Copy the new data
utlMemCopy(sNewData.GetParsePointer(), pPos, sNewData.GetLength());
pPos += sNewData.GetLength();
// NULL-terminator
*pPos++ = '\0';
// Free our original buffer and swap
if (m_pData)
delete [] GetBuffer();
m_pData = pNewBuffer + sizeof(DWORD);
}
示例15: ASSERT
void CFileName::ReplaceExtension(LPCTSTR pszNewExt)
{
ASSERT(pszNewExt);
if(_TCHAR('.')==*pszNewExt){
// Be tolerant of whether '.' is included in what we are passed:
pszNewExt++;
}
LPTSTR pch=GetBuffer(2+GetLength()+_tcslen(pszNewExt));
LPTSTR pcExt=_tcsrchr(pch,_TCHAR('.'));
if(NULL==pcExt || _tcschr(pcExt,cSep)){
// No existing extension
pcExt=pch+GetLength();
*pcExt++=_TCHAR('.');
}
_tcscpy(pcExt+1,pszNewExt);
ReleaseBuffer();
}