MCPcopy Create free account
hub / github.com/buggins/coolreader / streamToJByteArray

Method streamToJByteArray

android/jni/cr3java.cpp:163–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163jbyteArray CRJNIEnv::streamToJByteArray( LVStreamRef stream )
164{
165 if ( stream.isNull() )
166 return NULL;
167 int sz = (int)stream->GetSize();
168 if ( sz<10 || sz>2000000 )
169 return NULL;
170 jbyteArray array = env->NewByteArray(sz);
171 lUInt8 * array_data = (lUInt8 *)env->GetByteArrayElements(array, 0);\
172 lvsize_t bytesRead = 0;
173 stream->Read(array_data, sz, &bytesRead);
174 env->ReleaseByteArrayElements(array, (jbyte*)array_data, 0);
175 if ( bytesRead!=sz )
176 return NULL;
177 return array;
178}
179
180static void ConvertCRColorsToAndroid( lUInt8 * buf, int dx, int dy )
181{

Calls 3

isNullMethod · 0.45
GetSizeMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected