【问题标题】:ImageView data to Byte Array AndroidImageView 数据到字节数组 Android
【发布时间】:2014-08-01 15:30:33
【问题描述】:

我正在尝试使用 parse.com 数据库上传文件,语法需要我使用字节 []。我将在下面写语法:

byte[] data = "Working at Parse is great!".getBytes();
ParseFile file = new ParseFile("resume.png", data);
file.saveInBackground();
ParseObject jobApplication = new ParseObject("JobApplication");
jobApplication.put("applicantResumeFile", file);
jobApplication.saveInBackground();

我需要知道如何使用第一条指令获取字节[]中的ImageView数据并上传。

【问题讨论】:

    标签: android parsing bytearray


    【解决方案1】:

    @wisejoy 我有一个实现,但我认为它有点不同......希望它可以帮助你......干杯!!

                myBitmap = (Bitmap) data.getExtras().get("data");//here I set an image taken by the camera
                imageView.setImageBitmap(myBitmap);//I set it into an image view 
                imageView.buildDrawingCache();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();//and then I convert that image into a byteArray
                myBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                byte[] b = baos.toByteArray();
    
                encondedImage = android.util.Base64.encodeToString(b, Base64.DEFAULT);
                Log.e(TAG, "" + txt);
    

    【讨论】:

    • 非常感谢朋友。我查看了您的代码并学习了如何操作。你实际上猜到了我需要什么。伟大的! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    相关资源
    最近更新 更多