public GetBytes ( int i, long fieldOffset, byte buffer, int bufferoffset, int length ) : long | ||
i | int | The index of the column to retrieve |
fieldOffset | long | The zero-based index of where to begin reading the data |
buffer | byte | The buffer to write the bytes into |
bufferoffset | int | The zero-based index of where to begin writing into the array |
length | int | The number of bytes to retrieve |
return | long |
/// <summary> /// Reads the contents of a field as a byte array <br /> /// Assumes you did the locking! /// </summary> /// <param name="reader"></param> /// <param name="field">Field number to read from (default=first)</param> /// <returns></returns> protected static byte[] _GetBytes(SQLiteDataReader reader, int field = 0) { const int chunkSize = 2 * 1024; var buffer = new byte[chunkSize]; long fieldOffset = 0; using (var stream = new MemoryStream()) { int bytesRead; while ((bytesRead = (int)reader.GetBytes(field, fieldOffset, buffer, 0, buffer.Length)) > 0) { stream.Write(buffer, 0, bytesRead); fieldOffset += bytesRead; } return(stream.ToArray()); } }
//Metodo para conversion de imagenes de tipo BLOB a array de bytes public static byte[] getBytes(int columna,SqliteDataReader reader) { const int CHUNK_SIZE = 2 * 1024; byte[] buffer = new byte[CHUNK_SIZE]; long bytesRead; long fieldOffset = 0; int bufferoffset = 0; using (MemoryStream stream = new MemoryStream()) { while ((bytesRead = reader.GetBytes(columna, fieldOffset, buffer, bufferoffset, buffer.Length)) > 0) { stream.Write(buffer, 0, (int)bytesRead); fieldOffset += bytesRead; } return stream.ToArray(); } }
static int GetBytes(IntPtr L) { try { ToLua.CheckArgsCount(L, 6); Mono.Data.Sqlite.SqliteDataReader obj = (Mono.Data.Sqlite.SqliteDataReader)ToLua.CheckObject(L, 1, typeof(Mono.Data.Sqlite.SqliteDataReader)); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); long arg1 = LuaDLL.tolua_checkint64(L, 3); byte[] arg2 = ToLua.CheckByteBuffer(L, 4); int arg3 = (int)LuaDLL.luaL_checknumber(L, 5); int arg4 = (int)LuaDLL.luaL_checknumber(L, 6); long o = obj.GetBytes(arg0, arg1, arg2, arg3, arg4); LuaDLL.tolua_pushint64(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private static byte[] GetBytes(SQLiteDataReader reader) { const int CHUNK_SIZE = 2 * 1024; byte[] buffer = new byte[CHUNK_SIZE]; long bytesRead; long fieldOffset = 0; using (MemoryStream stream = new MemoryStream()) { while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0) { byte[] actualRead = new byte[bytesRead]; Buffer.BlockCopy(buffer, 0, actualRead, 0, (int)bytesRead); stream.Write(actualRead, 0, actualRead.Length); fieldOffset += bytesRead; } return stream.ToArray(); } }
static int ReadBinaryBlob(SqliteDataReader reader, int column, ref byte[] buffer) { long nread; // first, get the length of the buffer needed if ((nread = reader.GetBytes (column, 0, null, 0, buffer.Length)) > buffer.Length) Array.Resize (ref buffer, (int) nread); // read the certificate data return (int) reader.GetBytes (column, 0, buffer, 0, (int) nread); }