public byte[] queryFeature(string faceToken) { byte[] feature = null; ICursor cursor = null; try { if (mDBHelper == null) { return(feature); } SQLiteDatabase db = mDBHelper.ReadableDatabase; string where = "face_token = ? "; string[] whereValue = { faceToken }; cursor = db.Query(DBHelper.TABLE_FEATURE, null, where, whereValue, null, null, null); if (cursor != null && cursor.Count > 0 && cursor.MoveToNext()) { int dbId = cursor.GetInt(cursor.GetColumnIndex("_id")); feature = cursor.GetBlob(cursor.GetColumnIndex("feature")); } } catch (Java.Lang.Exception) { closeCursor(cursor); } return(feature); }
byte[] GetThumbnailBytes() { string lookupColumn = (IsAggregate) ? ContactsContract.ContactsColumns.LookupKey : ContactsContract.RawContactsColumns.ContactId; ICursor c = null; try { c = this.content.Query(ContactsContract.Data.ContentUri, new[] { ContactsContract.CommonDataKinds.Photo.PhotoColumnId, ContactsContract.DataColumns.Mimetype }, lookupColumn + "=? AND " + ContactsContract.DataColumns.Mimetype + "=?", new[] { Id, ContactsContract.CommonDataKinds.Photo.ContentItemType }, null); while (c.MoveToNext()) { byte[] tdata = c.GetBlob(c.GetColumnIndex(ContactsContract.CommonDataKinds.Photo.PhotoColumnId)); if (tdata != null) { return(tdata); } } } finally { if (c != null) { c.Close(); } } return(null); }
public byte[] getSound(string key) { sqliteDB = db.WritableDatabase; byte[] soundArray = new byte[25000]; try { StringBuilder sb = new StringBuilder(); sb.Append("SELECT sound FROM sounds where trim(name) = "); sb.Append(" '"); sb.Append(key); sb.Append("' "); ICursor selectData = sqliteDB.RawQuery(sb.ToString(), null); if (selectData.Count > 0) { selectData.MoveToFirst(); do { soundArray = selectData.GetBlob(0); }while (selectData.MoveToNext()); selectData.Close(); } return(soundArray); } catch (Exception e) { return(null); } }
public byte[] getImage(string key) { sqliteDB = db.WritableDatabase; byte[] imageArray = new byte[25000]; try { StringBuilder sb = new StringBuilder(); sb.Append("SELECT image FROM Images where trim(name) = "); sb.Append("'"); sb.Append(key); sb.Append("' "); ICursor selectData = sqliteDB.RawQuery(sb.ToString(), null); if (selectData.Count > 0) { selectData.MoveToFirst(); do { imageArray = selectData.GetBlob(0); }while (selectData.MoveToNext()); selectData.Close(); } return(imageArray); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } }
public Bitmap ReturnDrawableBase(long id, string path) { string[] col = { "ColumnBitmap" }; string[] param = { path }; cursor = WritableDatabase.Query("ContentTable", col, "ColumnPath = ?", param, null, null, null); cursor.MoveToFirst(); byte[] array = cursor.GetBlob(cursor.GetColumnIndex(COLUMN_BITMAP)); Bitmap b = Multitools.ConvertToBitmap(array); return(b); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { // var imageView = FindViewById<ImageView>(Resource.Id.image); image.BuildDrawingCache(true); Bitmap bmap = image.GetDrawingCache(true); // image.SetImageURI(data.Data); MemoryStream stream = new MemoryStream(); bmap.Compress(Bitmap.CompressFormat.Png, 100, stream); byte[] img = stream.ToArray(); DBAdapter db = new DBAdapter(this); db.openDb(); long i = db.insertImage(img); if (i > 0) { Toast.MakeText(this, "Insert", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Insert Failed..", ToastLength.Short).Show(); } ICursor c = db.showImage(); if (c != null) { c.MoveToFirst(); do { img1 = c.GetBlob(1); } while (c.MoveToNext()); } MemoryStream ms = new MemoryStream(); Bitmap n1 = BitmapFactory.DecodeByteArray(img1, 0, img1.Length); // n1.Compress(Bitmap.CompressFormat.Jpeg, 100, ms); image.SetImageBitmap(n1); db.closeDb(); } }
public byte[] GetImageData() { ClipboardManager clipboard = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService); ContentResolver cr = Forms.Context.ContentResolver; ClipData clip = clipboard.PrimaryClip; byte[] p = null; if (clip != null) { // Gets the first item from the clipboard data ClipData.Item item = clip.GetItemAt(0); // Tries to get the item's contents as a URI Android.Net.Uri pasteUri = item.Uri; // If the clipboard contains a URI reference if (pasteUri != null) { // Is this a content URI? String uriMimeType = cr.GetType(pasteUri); // If the return value is not null, the Uri is a content Uri if (uriMimeType != null) { // Does the content provider offer a MIME type that the current application can use? if (uriMimeType.StartsWith("image/")) { // Get the data from the content provider. ICursor pasteCursor = cr.Query(pasteUri, null, null, null, null); // If the Cursor contains data, move to the first record if (pasteCursor != null) { if (pasteCursor.MoveToFirst()) { p = pasteCursor.GetBlob(0); } } // close the Cursor pasteCursor.Close(); } } } } return(p); }
public List <Feature> queryFeatureByGroupId(string groupId) { List <Feature> featureList = new List <Feature>(); ICursor cursor = null; try { if (mDBHelper == null) { return(featureList); } SQLiteDatabase db = mDBHelper.ReadableDatabase; string where = "group_id = ? "; string[] whereValue = { groupId }; cursor = db.Query(DBHelper.TABLE_FEATURE, null, where, whereValue, null, null, null); while (cursor != null && cursor.Count > 0 && cursor.MoveToNext()) { int dbId = cursor.GetInt(cursor.GetColumnIndex("_id")); string faceToken = cursor.GetString(cursor.GetColumnIndex("face_token")); byte[] featureContent = cursor.GetBlob(cursor.GetColumnIndex("feature")); string userId = cursor.GetString(cursor.GetColumnIndex("user_id")); long updateTime = cursor.GetLong(cursor.GetColumnIndex("update_time")); long ctime = cursor.GetLong(cursor.GetColumnIndex("ctime")); string imageName = cursor.GetString(cursor.GetColumnIndex("image_name")); Feature feature = new Feature(); feature.setFaceToken(faceToken); feature.setFeature(featureContent); feature.setCtime(ctime); feature.setUpdateTime(updateTime); feature.setGroupId(groupId); feature.setUserId(userId); feature.setImageName(imageName); featureList.Add(feature); } } catch (Java.Lang.Exception) { closeCursor(cursor); } return(featureList); }
/// <summary> /// Отображение на экран рецепта и изображения блюда /// </summary> private void ShowData() { ICursor selectData = sqliteDB.RawQuery($"select * from db where name='{Data.StringData}'", new string[] { }); selectData.MoveToFirst(); tv1 = FindViewById <TextView>(Resource.Id.tv1); tv2 = FindViewById <TextView>(Resource.Id.tv2); iv = FindViewById <ImageView>(Resource.Id.iv); tv1.Text = selectData.GetString(selectData.GetColumnIndex("name")); byte[] byteArray = selectData.GetBlob(selectData.GetColumnIndex("picture")); Bitmap bmp = BitmapFactory.DecodeByteArray(byteArray, 0, byteArray.Length); ImageView image = (ImageView)FindViewById(Resource.Id.iv); image.SetImageBitmap(bmp); tv2.Text = selectData.GetString(selectData.GetColumnIndex("recipe")); selectData.Close(); }
public static byte[] getBlob(this ICursor cursor, int columnIndex) { return(cursor.GetBlob(columnIndex)); }