MCPcopy Create free account
hub / github.com/carbonengine/trinity / PySetMipRawData

Method PySetMipRawData

trinity/Tr2HostBitmap_Blue.cpp:125–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125PyObject* Tr2HostBitmap::PySetMipRawData( PyObject* self, PyObject* args )
126{
127 unsigned int mipLevel = 0;
128 Py_buffer buffer;
129 if( !PyArg_ParseTuple( args, "iw*", &mipLevel, &buffer ) )
130 return nullptr;
131 ON_BLOCK_EXIT( [&] { PyBuffer_Release( &buffer ); } );
132
133 Tr2HostBitmap* pThis = BluePythonCast<Tr2HostBitmap*>( self );
134 if( !pThis->IsValid() )
135 {
136 PyErr_SetString( PyExc_ValueError, "invalid bitmap" );
137 return nullptr;
138 }
139
140 if( mipLevel >= pThis->GetTrueMipCount() )
141 {
142 PyErr_SetString( PyExc_ValueError, "mip level out of range" );
143 return nullptr;
144 }
145
146 if( buffer.len < Py_ssize_t( pThis->GetMipSize( mipLevel ) ) )
147 {
148 PyErr_SetString( PyExc_ValueError, "buffer too small" );
149 return nullptr;
150 }
151
152 memcpy( pThis->GetMipRawData( mipLevel ), buffer.buf, pThis->GetMipSize( mipLevel ) );
153 Py_RETURN_NONE;
154}
155
156
157PyObject* Tr2HostBitmap::PyCreateFromFile( PyObject* args )

Callers

nothing calls this directly

Calls 3

GetTrueMipCountMethod · 0.80
GetMipSizeMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected