forked from carbonengine/imagetools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryOutputHandler.cpp
More file actions
47 lines (40 loc) · 895 Bytes
/
Copy pathMemoryOutputHandler.cpp
File metadata and controls
47 lines (40 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright © 2014 CCP ehf.
#include "StdAfx.h"
#include "MemoryOutputHandler.h"
MemoryOutputHandler::MemoryOutputHandler()
:m_streamSize( 0 )
{
}
size_t MemoryOutputHandler::GetSize() const
{
return m_streamSize;
}
const void* MemoryOutputHandler::GetData() const
{
return m_buffer.get();
}
void MemoryOutputHandler::beginImage(int size, int width, int height, int depth, int face, int miplevel)
{
}
bool MemoryOutputHandler::writeData(const void * data, int size)
{
if( size <= 0 )
{
return true;
}
if( m_streamSize + size > m_buffer.size() )
{
const size_t MEGABYTE = 1024 * 1024;
m_buffer.resize( "MemoryOutputHandler", ( ( m_streamSize + size + MEGABYTE - 1 ) / MEGABYTE ) * MEGABYTE );
if( !m_buffer )
{
return false;
}
}
memcpy( m_buffer.get() + m_streamSize, data, size );
m_streamSize += size;
return true;
}
void MemoryOutputHandler::endImage()
{
}