示例#1
0
 public OcrTextSnippet(string title, IEnumerable<Tuple<string, Bitmap>> transcriptions) : base(title, "")
 {
     foreach (var (content, bitmap) in transcriptions)
     {
         Transcriptions.Add(new Tuple<string, string>(content, BitmapToBase64Converter.Convert(bitmap)));
     }
 }
示例#2
0
        public OcrSnippetWindow(PluginEngine pluginEngine, OcrTextSnippet abstractSnippet = null)
        {
            _pluginEngine = pluginEngine;

            InitializeComponent();
            Model = new OcrSnippetWindowModel();

            if (abstractSnippet != null)
            {
                TxtTitle.Text = abstractSnippet.Identifier;

                foreach (var(content, base64) in abstractSnippet.Transcriptions)
                {
                    var bitmap = BitmapToBase64Converter.ConvertBack(base64);
                    Model.BitmapPairs.Add(new BitmapTextPair(bitmap.ToImageSource(), null, content));
                }
            }
        }
示例#3
0
        public static void LoadImage(Activity context, BigDaysItemModel item)
        {
            switch (item._ImageStorage)
            {
            case (int)LocationPicture.ResourcesImage:
                string    path_main_bg_def = item._Image.Replace("small", "");
                Resources res          = context.Resources;
                int       imageID      = res.GetIdentifier(path_main_bg_def.Replace(".jpg", ""), "drawable", context.PackageName);
                int       imageIDsmall = res.GetIdentifier(item._Image.Replace(".jpg", ""), "drawable", context.PackageName);
                item._BigImg   = DecodeSampledBitmapFromResource(res, imageID, (int)MainActivity._DisplayWidth, (int)MainActivity._DisplayWidth, context);
                item._SmallImg = DecodeSampledBitmapFromResource(res, imageIDsmall, 70, 70, context);
                break;

            case (int)LocationPicture.Base64Image:
                item._BigImg   = BitmapToBase64Converter.Base64ToBitmap(item.ImageBase64);
                item._SmallImg = item._BigImg;
                break;

            case (int)LocationPicture.FileImage:
                item._BigImg   = LoadAndResizeBitmap(item._Image, (int)MainActivity._DisplayWidth, (int)MainActivity._DisplayWidth);
                item._SmallImg = LoadAndResizeBitmap(item._Image, 70, 70);
                break;
            }
        }
示例#4
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (resultCode == Result.Ok)
            {
                switch (requestCode)
                {
                case 0:
                    if (data == null)
                    {
                        break;
                    }
#if _TRIAL_
                    int imgPos = data.GetIntExtra("pos", 0);
                    if (imgPos > 1)
                    {
                        AlertDialog.Builder builder;
                        builder = new AlertDialog.Builder(this);
                        builder.SetTitle("Free Version");
                        builder.SetMessage("You can select only 2 first images in free version. Please purchase full version (no ad banner) to select any images.\n\nBy clicking \"Buy Now\" you will redirect to Full version (no ad banner) purchase page.");
                        builder.SetCancelable(false);
                        builder.SetPositiveButton("Buy Now", delegate {
                            Intent browserIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(Constants.VersionLink));
                            StartActivity(browserIntent);
                        });
                        builder.SetNegativeButton("Continue", delegate {  });
                        builder.Show();
                    }
                    else
                    {
                        _ImgPath = data.GetStringExtra("image");
                        try{
                            Resources res     = Resources;
                            int       imageID = res.GetIdentifier(_ImgPath.Replace(".jpg", ""), "drawable", PackageName);
                            _ImageArea.SetImageDrawable(res.GetDrawable(imageID));
                        } catch (OutOfMemoryError em) {
                            AlertDialog.Builder builder;
                            builder = new AlertDialog.Builder(this);
                            builder.SetTitle("Error");
                            builder.SetMessage("Out Of Memory Error №98");
                            builder.SetCancelable(false);
                            builder.SetPositiveButton("OK", delegate { Finish(); });
                            builder.Show();
                        }
                        _ImageStorageNum = LocationPicture.ResourcesImage;
                    }
#else
                    _ImgPath = data.GetStringExtra("image");
                    try
                    {
                        Resources res     = Resources;
                        int       imageID = res.GetIdentifier(_ImgPath.Replace(".jpg", ""), "drawable", PackageName);
                        _ImageArea.SetImageDrawable(res.GetDrawable(imageID));
                    }
                    catch (OutOfMemoryError)
                    {
                        AlertDialog.Builder builder;
                        builder = new AlertDialog.Builder(this);
                        builder.SetTitle("Error CodeBlock №99");
                        builder.SetMessage("Out Of Memory Error");
                        builder.SetCancelable(false);
                        builder.SetPositiveButton("OK", delegate { Finish(); });
                        builder.Show();
                    }
                    _ImageStorageNum = LocationPicture.ResourcesImage;
                                                #endif
                    break;

                case (int)RequestCode.PickImage:
                    try
                    {
                        if (data == null)
                        {
                            break;
                        }
                        var imagesURl = data.GetStringExtra("image");

                        Constants.ImageBtmUri = string.IsNullOrEmpty(imagesURl) ? data.DataString : imagesURl;

                        var IntentShareActivity = new Intent(this, typeof(ImagePreview));
                        StartActivityForResult(IntentShareActivity, (int)RequestCode.ReturnPickImagePath);
                    }
                    catch (OutOfMemoryError)
                    {
                        AlertDialog.Builder builder;
                        builder = new AlertDialog.Builder(this);
                        builder.SetTitle("Error CodeBlock №100");
                        builder.SetMessage("Out Of Memory Error");
                        builder.SetCancelable(false);
                        builder.SetPositiveButton("OK", delegate { Finish(); });
                        builder.Show();
                    }
                    break;

                case (int)RequestCode.ReturnPickImagePath:

                    if (data != null)
                    {
                        string result = data.GetStringExtra("result");
                        _ImageArea.SetImageBitmap(Constants.ImageBtm);
                        _ImageStorageNum = LocationPicture.Base64Image;

                        _ImageBase64 = BitmapToBase64Converter.BitmapToBase64(Constants.ImageBtm);
                    }
                    else
                    {
                        AlertDialog.Builder builder;
                        builder = new AlertDialog.Builder(this);
                        builder.SetTitle("Error CodeBlock №66");
                        builder.SetMessage("ReturnPickImagePath is null");
                        builder.SetCancelable(false);
                        builder.SetPositiveButton("OK", delegate { Finish(); });
                        builder.Show();
                    }
                    break;

                case (int)RequestCode.CameraImage:
                    try
                    {
                        Intent          mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                        Android.Net.Uri contentUri      = Android.Net.Uri.FromFile(App._file);
                        mediaScanIntent.SetData(contentUri);
                        SendBroadcast(mediaScanIntent);

                        Constants.ImageBtmUri = contentUri.ToString();

                        var IntentShareActivity2 = new Intent(this, typeof(ImagePreview));
                        StartActivityForResult(IntentShareActivity2, (int)RequestCode.ReturnPickImagePath);
                    }
                    catch (OutOfMemoryError)
                    {
                        AlertDialog.Builder builder;
                        builder = new AlertDialog.Builder(this);
                        builder.SetTitle("Error CodeBlock №101");
                        builder.SetMessage("Out Of Memory Error");
                        builder.SetCancelable(false);
                        builder.SetPositiveButton("OK", delegate { Finish(); });
                        builder.Show();
                    }
                    break;

                case (int)RequestCode.Repeat:
                    _RepeatNum         = data.GetIntExtra("Num", 0);
                    _UiEditRepeat.Text = _RepeatStrs[_RepeatNum];
                    break;

                case (int)RequestCode.Alerts:
                    _AlertStr = data.GetStringExtra("Alert");
                    break;

                default:
                    break;
                }
            }
        }