Giter VIP home page Giter VIP logo

tushuo's Introduction

图说

图说,一个将图片转化为文字矩阵的Android APP

下载链接 http://www.coolapk.com/apk/com.egguncle.imagetohtml

基本功能:

选择图片,输入标题和填充文字,生成对应的html文件

主界面

图片选择

原图

生成效果

生成过程

        for (int i = 0; i < height - 1; i += blockSize) {
            for (int j = 0; j < width - 1; j += blockSize) {
                //  Log.i(TAG, "imageToHtml: - "+i+"  "+j);
                int pixel = 0;
                //获取对应坐标的颜色信息
                pixel = bitmap.getPixel(j, i);
                int red = Color.red(pixel);
                int green = Color.green(pixel);
                int blue = Color.blue(pixel);
                int alpha = Color.alpha(pixel);
                htmlStr.append("<font style=color:rgba(" + red + "," + green + "," + blue + "," + alpha + ") >" + chars[n++ % content.length()] + "</font>");

            }
            htmlStr.append("<br>\n\n");
        }

整个过程还是很简单的,直接读取一些坐标信息,获取颜色值,转化为html代码。

PS:进行这一步之前先对图片进行了缩放,使图片有一个相对好处理的尺寸,使最后生成的html页面不至于太大导致webview在加载时出现ANR,至于到底图片改缩放多少,我自己也还在摸索,如果你有更好的图片尺寸或者对于html生成加载有什么更好的建议,请给我留言。

更新

2017-5-5 增加将webview内容保存为图片文件的功能

2017-5-22 增加将定制化页面效果的功能,可以设置文字大小,生成的页面尺寸,背景颜色,亮度参数。

tushuo's People

Contributors

egguncle avatar

Stargazers

Bai HongHua avatar  avatar 一生热爱 avatar 长青空手道 avatar  avatar Daemonth avatar  avatar

Watchers

James Cloos avatar  avatar

tushuo's Issues

如题

你这个我进入webViewActivity页面以后生成图片后会卡死是怎么回答?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.