中文汉字注音,汉字转拼音,支持图片识别文字,支持结果转图下载,附上小程序核心源码
生活随笔
收集整理的這篇文章主要介紹了
中文汉字注音,汉字转拼音,支持图片识别文字,支持结果转图下载,附上小程序核心源码
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
“文字注音”小程序在微信、字節(jié)跳動(dòng)、支付寶、QQ等小程序平臺(tái)同步上線,微信、頭條、抖音、支付寶、QQ中搜索“文字注音”即可獲得。
一、功能
漢字轉(zhuǎn)拼音,支持圖片識(shí)別文字,支持結(jié)果轉(zhuǎn)圖下載。該款小程序能夠輕松將文字注音后輸出,無(wú)需授權(quán),無(wú)需注冊(cè),即來(lái)即用。你還可以用它來(lái)識(shí)別圖片中的文字后注音,或者隨時(shí)拍照后識(shí)別文字再注音。同時(shí)支持注音完成后復(fù)制拼音,支持將結(jié)果保存成圖片下載到手機(jī)本地。歡迎掃描下面的各平臺(tái)得小程序碼來(lái)嘗試一下。
二、平臺(tái)小程序碼
| 微信小程序 | 抖音/頭條小程序 | QQ小程序 |
三、核心源碼:
原文鏈接:https://www.i847.cn/article/3033.html
部分源碼預(yù)覽:
save:function(){var _that = this;_that.down = true;//先設(shè)置canvas得高度_that.canvasHeight = _that.canvasStaticHeight;_that.showCanvas = true;setTimeout(function(){var ctx = uni.createCanvasContext("canvas",_that);ctx.rect(0, 0, _that.canvasWidth, _that.canvasHeight);ctx.setFillStyle('white');ctx.fill();ctx.setFillStyle('black');// 字體大小ctx.setFontSize(14);var fontHeight = 14;// 寬度var width = _that.canvasWidth;// 橫向間隔var transverse = 9;// 縱向小間隔var portraitSmall = 4;// 縱向大間隔var portraitBig = 7;// 外間距var padding = 20;// 橫向距離累計(jì)var transverseCumulative = padding;// 縱向距離累計(jì)var portraitCumulative = padding;var lineHeight = portraitSmall + portraitBig + (fontHeight*2);for(var i=0;i<_that.list.length;i++){// canvas高度變化if(i==0){_that.canvasHeight = portraitCumulative + lineHeight;setTimeout(function(){},10);}var item = _that.list[i];var metrics = ctx.measureText(item.pinyin);var tempX = transverseCumulative + transverse + metrics.width;if(tempX > (width-padding) || item.pinyin=="enter"){transverseCumulative = padding;portraitCumulative = portraitCumulative + lineHeight;_that.canvasHeight = portraitCumulative + lineHeight;setTimeout(function(){},10);}if(item.pinyin!="enter"){var x1;if(transverseCumulative==padding){x1 = transverseCumulative;}else{x1 = transverseCumulative + transverse;}var y1 = portraitCumulative;ctx.fillText(item.pinyin, x1, y1);var x2 = x1;var y2 = y1 + portraitSmall + fontHeight;ctx.fillText(item.value,x2, y2);transverseCumulative = x1 + metrics.width;}}ctx.draw();setTimeout(function(){uni.canvasToTempFilePath({width: _that.canvasWidth,height: _that.canvasHeight,destWidth: _that.canvasWidth * _that.pixelRatio,destHeight: _that.canvasHeight * _that.pixelRatio,canvasId: 'canvas',success: function(res) {uni.saveImageToPhotosAlbum({filePath: res.tempFilePath,success:function(){uni.showToast({title:"保存成功"})},complete:function(){_that.showCanvas = false;_that.down = false;}});},fail:function(e){console.log(e);_that.showCanvas = false;_that.down = false;}})},100);},100); }?
總結(jié)
以上是生活随笔為你收集整理的中文汉字注音,汉字转拼音,支持图片识别文字,支持结果转图下载,附上小程序核心源码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux下的lds连接脚本详解,Lin
- 下一篇: 总结2012年世界经济形势主要特征