中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

深圳網(wǎng)站建設(shè)公司的英文名是網(wǎng)站seo分析工具

深圳網(wǎng)站建設(shè)公司的英文名是,網(wǎng)站seo分析工具,做圖軟件ps下載網(wǎng)站,設(shè)計網(wǎng)站建設(shè)常州之前我有一篇帖子《kfb格式文件轉(zhuǎn)jpg格式》講述到 kfb > tif > jpg,但是針對于超大tif中的大圖是無法順利提取的,就算是能順利提取,試想一下,2G的tif文件,如果能提取處理最大的那張圖,并且在不壓縮的…

? ? ? ? 之前我有一篇帖子《kfb格式文件轉(zhuǎn)jpg格式》講述到 kfb ===> tif ===> jpg,但是針對于超大tif中的大圖是無法順利提取的,就算是能順利提取,試想一下,2G的tif文件,如果能提取處理最大的那張圖,并且在不壓縮的情況下,jpg大圖大小高達1G,前端也是無法順利加載展示的。

????????這里我為大家?guī)砹私鉀Q方案:將tif中最大的那張圖切割成 x * y?份,之后讓前端去對每一份進行渲染加載。經(jīng)過了兩周時間,百度或是谷歌的雷都被我踩完了(搜索結(jié)果都不怎么靠譜)。多次實驗后,總算是成功了。

????????針對與tif中的最大的那張圖的切割,我總結(jié)出了切割實現(xiàn)方法,僅供參考。

利用jai-imageio進行處理

package com.lonzh.utils;import javax.imageio.IIOException;
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.FileImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;/*** 圖片切割** @author DaiHaijiao*/
public class ImgCutUtil {public static void main(String[] args) throws Exception {cut("D:\\病理切片\\教學切片(新)\\BL-01-11 心肌梗死.tif");}/*** @param imageWidth         圖片寬度* @param imageHeight        圖片高度* @param bisectionNumWidth  寬度方向等分數(shù)* @param bisectionNumHeight 高度方向等分數(shù)*/private static List<ImgCutUtil.Position> listPosition(int imageWidth, int imageHeight, int bisectionNumWidth, int bisectionNumHeight) {List<ImgCutUtil.Position> list = new ArrayList<>();//每個部分的寬度int partWidth = imageWidth / bisectionNumWidth;//寬方向的余數(shù)int remainderWidth = imageWidth % bisectionNumWidth;//每個部分的高度int partHeight = imageHeight / bisectionNumHeight;//高方向的余數(shù)int remainderHeight = imageHeight % bisectionNumHeight;for (int i = 0; i < bisectionNumWidth; i++) {for (int j = 0; j < bisectionNumHeight; j++) {//左下角 x 坐標int left = i * partWidth;//左下角 y 坐標int bottom = j * partHeight;//右上角 x 坐標int right = i == bisectionNumWidth - 1 ? (i + 1) * partWidth + remainderWidth : (i + 1) * partWidth;//右上角 y 坐標int top = j == bisectionNumWidth - 1 ? (j + 1) * partHeight + remainderHeight : (j + 1) * partHeight;
//                System.out.println("第 " + (i * bisectionNumWidth + j + 1) + " 等分:");
//                System.out.println("左下角坐標:(" + left + ", " + bottom + ")");
//                System.out.println("右上角坐標:(" + right + ", " + top + ")");list.add(new ImgCutUtil.Position(left, bottom, right, top));}}return list;}public static List<File> cut(String tifPath) {List<File> jpgFileList = new ArrayList<>();File tifFile = new File(tifPath);String outPutDirPath = tifPath.substring(0, tifPath.lastIndexOf(".")) + "_large_img" + File.separator;File outDirPath = new File(outPutDirPath);if (!outDirPath.exists()) {outDirPath.mkdir();}try (FileImageInputStream fis = new FileImageInputStream(tifFile)) {Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("TIFF");if (!readers.hasNext()) {throw new IIOException("No suitable image reader found!");}ImageReader reader = readers.next();reader.setInput(fis, true);int w = reader.getWidth(0);int h = reader.getHeight(0);int bisectionNumWidth = 5, bisectionNumHeight = 5;List<Position> positions = listPosition(w, h, bisectionNumWidth, bisectionNumHeight);for (int i = 0; i < positions.size(); i++) {ImageReadParam imageReadParam = new ImageReadParam();Position position = positions.get(i);System.out.println(position.left + "---" + position.bottom + "---" + (position.right - position.left) + "---" + (position.top - position.bottom));imageReadParam.setSourceRegion(new Rectangle(position.left, position.bottom, position.right - position.left, position.top - position.bottom));BufferedImage image = reader.read(0, imageReadParam);File file = new File(outPutDirPath + i + ".jpg");ImageIO.write(image, "jpg", ImageIO.createImageOutputStream(file));jpgFileList.add(file);}} catch (IOException e) {e.printStackTrace();}return jpgFileList;}static class Position {//左下角 x 坐標private Integer left;//左下角 y 坐標private Integer bottom;//右上角 x 坐標private Integer right;//右上角 y 坐標private Integer top;public Position(Integer left, Integer bottom, Integer right, Integer top) {this.left = left;this.bottom = bottom;this.right = right;this.top = top;}@Overridepublic String toString() {return "Position{" +"left=" + left +", bottom=" + bottom +", right=" + right +", top=" + top +'}';}}}

上述代碼說明:

1.?代碼運行需要引用maven依賴

        <dependency><groupId>javax.media.jai</groupId><artifactId>jai-imageio-core</artifactId><version>1.4.0</version></dependency>

有C幣的朋友可直接移步j(luò)ar文件下載傳送門(jar引入方式見:我的另一篇文章《本地Maven倉庫導入外部jar》)

2.?main方法中的測試文件較大,高達1.64G

3.?切割比較吃內(nèi)存,電腦配置太低時謹慎運行,避免電腦卡死

4.?代碼中我是將該tif切割成了 5 * 5?份,切割完后會在該tif文件所在文件內(nèi)產(chǎn)生一個新的文件夾(里面就是所有切割后的小圖)

裁剪后的圖片圖號如下:

圖序如下:

不管是幾乘幾的切割,圖序排列規(guī)則都是一樣的模式,如下圖規(guī)則:

如果你對圖序感興趣,或是我的這種圖序覺得前端不好使用,你可以再次研究修改listPositioin方法以達到你所需的圖序。

5.?計算每一份的點坐標位置時注意:tif的寬和高未必能被要切割成的寬份數(shù)和高的份數(shù)整除,所以注意余數(shù)問題。我的那個listPosition方法中已經(jīng)對于余數(shù)進行了處理,詳見那塊代碼。

6.?代碼執(zhí)行超大tif文件裁剪會報錯,報錯地方如圖:

????????報錯原因就是tif的寬*高的值大于了Integer的最大值。解決辦法很簡單,報錯的這個class文件位于rt.jar下面的javax.imgio下的ImageReader.class,而解決辦法就在此。
? ? ? ? 我們在我們的項目中按照這個包路徑創(chuàng)建一個包,并在該包下創(chuàng)建這個類,類里面的內(nèi)容直接將ImageReader.class的內(nèi)容拷貝過來,之后修改報錯的地方:

修改完后重新編譯項目,就會在target下面生產(chǎn)一個ImageReader.class文件。我們只需要替換jar包中的這個class即可。

替換前先關(guān)閉idea,找到項目所用到的rt.jar

如果打不開,自己下載個7z就能打開了,之后把我們編譯后的那個class拖進去即可完成替換

最后重新打開idea運行代碼即可

? ? ? ?

????????

http://www.risenshineclean.com/news/52177.html

相關(guān)文章:

  • 做資源網(wǎng)站怎么不封今日新聞內(nèi)容
  • 利用對象儲存做網(wǎng)站友情鏈接免費發(fā)布平臺
  • 網(wǎng)站展示型推廣北京網(wǎng)絡(luò)推廣有哪些公司
  • 給網(wǎng)站做壓力測試全國新冠疫苗接種率
  • 建站公司見客戶沒話說b2b商務平臺
  • 衡水建網(wǎng)站百度搜索風云排行榜
  • 網(wǎng)站商城如何獲取流量成都網(wǎng)絡(luò)營銷推廣
  • 做行業(yè)分析的網(wǎng)站百度指數(shù)網(wǎng)址是什么
  • 論壇建站哪個比較好廣點通投放平臺
  • 谷歌瀏覽器怎么刪除2345網(wǎng)址導航百度產(chǎn)品優(yōu)化排名軟件
  • 免費瀏覽的網(wǎng)站資源平臺
  • 簡單做網(wǎng)站百度外鏈查詢工具
  • 廣安網(wǎng)站seoweb前端培訓費用大概多少
  • 企業(yè)所得稅一般交多少谷歌廣告優(yōu)化師
  • 什么是網(wǎng)站死鏈鄭州網(wǎng)絡(luò)推廣
  • 多個網(wǎng)站 備案我的百度賬號
  • 深圳網(wǎng)站建設(shè)定制sem是什么工作
  • 承德做網(wǎng)站優(yōu)化免費二級域名申請網(wǎng)站
  • 網(wǎng)站建設(shè)課程學習百度推廣中心
  • wordpress 406優(yōu)化關(guān)鍵詞排名
  • 制作網(wǎng)站協(xié)議公司市場營銷策劃方案
  • 請人做網(wǎng)站合同網(wǎng)址信息查詢
  • 做二手房網(wǎng)站有哪些百度禁止seo推廣
  • 開發(fā)安卓應用上海優(yōu)化seo排名
  • 詳情頁設(shè)計排版電商網(wǎng)站怎樣優(yōu)化
  • 西寧網(wǎng)站運營公司今日熱點新聞2022
  • 怎樣做網(wǎng)站國外建站系統(tǒng)
  • 手機網(wǎng)站跳轉(zhuǎn)怎么做seo排名啥意思
  • 動態(tài)網(wǎng)站開發(fā)的主要技術(shù)百度推廣計劃
  • 如何做攝影網(wǎng)站今日十大熱點新聞