开发者

Android :: BitmapFactrory Cuts off image

开发者 https://www.devze.com 2023-02-20 08:59 出处:网络
We are trying 开发者_运维知识库a prototype using Google chart api. http://chart.apis.google.com/chart?chf=bg,s,000000&chxs=0,FFFFFF00,9.5&chxt=x&chs=500x300&cht=p3&chco=3072F3|FF

We are trying 开发者_运维知识库a prototype using Google chart api.

http://chart.apis.google.com/chart?chf=bg,s,000000&chxs=0,FFFFFF00,9.5&chxt=x&chs=500x300&cht=p3&chco=3072F3|FF9900|80C65A|990066&chd=t:50,5,5,40&chdl=50%C2%B0%20Apples|5%C2%B0%20Oranges|5%C2%B0%20Dates|40%C2%B0%20Strawberries&chdlp=b&chp=0.1

Android :: BitmapFactrory Cuts off image

the problem is when we see the chart in the browser it displays the legend. but when we use the BitmapFactory to download the image to an ImageView or even SD card the Legend goes missing (this happens irrespective of where the legend is placed top, bottom, left or right).

here is the code

private Bitmap loadChart(URL url){
    Bitmap chart = null;   

    try{            
        HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection();
        httpConnection.setDoInput(true);
        httpConnection.connect();

        InputStream is = httpConnection.getInputStream();           
        chart = BitmapFactory.decodeStream(is);


    } catch (IOException e) {       
        e.printStackTrace();
    }

    //MediaStore.Images.Media.insertImage(getContentResolver(), chart, "chart.png", "chart.png");

    return chart;
}

here is the image which was downloaded by the commented line.

we also noticed that, the dimension of the chart specified in URL (chs=500x300) matches with the image dimension as well.

Android :: BitmapFactrory Cuts off image


Ended up using webview which handles url encoding without any additional effort.

0

精彩评论

暂无评论...
验证码 换一张
取 消