相关疑难解决方法(0)

裁剪方形图像到圆圈 - 以编程方式

我正在寻找过去的一天,但我没有成功.

我从API获取图像,然后使用以下代码将其下载到位图文件.

private Bitmap DownloadImage(String URL) 
    {
        Bitmap bitmap = null;
        InputStream in = null;
        try 
        {
            in = OpenHttpConnection(URL);
            bitmap = BitmapFactory.decodeStream(in);
            in.close();
        }
        catch (IOException e1) 
        {
            e1.printStackTrace();
        }
        return bitmap;
    }

    private InputStream OpenHttpConnection(String urlString) throws IOException 
    {
        InputStream in = null;
        int response = -1;

        URL url = new URL(urlString);
        URLConnection conn = url.openConnection();

        if (!(conn instanceof HttpURLConnection))
            throw new IOException("Not an HTTP connection");

        try 
        {
            HttpURLConnection httpConn = (HttpURLConnection) conn;
            httpConn.setAllowUserInteraction(false);
            httpConn.setInstanceFollowRedirects(true);
            httpConn.setRequestMethod("GET");
            httpConn.connect();

            response …
Run Code Online (Sandbox Code Playgroud)

android image crop android-canvas

21
推荐指数
3
解决办法
5万
查看次数

标签 统计

android ×1

android-canvas ×1

crop ×1

image ×1