第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

SonarLint 警告:降低圖像分塊的認(rèn)知復(fù)雜度(16 而不是 15)

SonarLint 警告:降低圖像分塊的認(rèn)知復(fù)雜度(16 而不是 15)

犯罪嫌疑人X 2023-09-13 15:23:48
我編寫(xiě)了一個(gè)函數(shù),其目的是獲取從重新縮放的輸入圖像定義的子圖像的集合(這些子圖像稱為“重新縮放的輸入圖像的重新縮放的塊”)并將這些重新縮放的塊重新組裝成輸出整個(gè)圖像(其尺寸是輸入圖像的那些,重新縮放)。所有塊都具有相同的尺寸。該函數(shù)定義如下。問(wèn)題是 SonarLint 警告我認(rèn)知復(fù)雜度是 16 而不是 15,而且我不想更改這個(gè)默認(rèn)的 SonarLint 限制。我能做什么?該功能的描述如下,代碼如下:final BufferedImage reassembleChunksInASingleImage(final int inputImageWidth, final int inputImageHeight, final int scalingCoefficient, final int chunkWidth, final int chunkHeight, final List<BufferedImage> theChunks) {    logger.log(Level.INFO, "Reassembling...");    final int reassembled_chunks_image_width = scalingCoefficient * inputImageWidth;    final int reassembledChunksImageHeight = scalingCoefficient * inputImageHeight;    final int rescaled_chunk_width = scalingCoefficient * chunkWidth;    final int rescaledChunkHeight = scalingCoefficient * chunkHeight;    final BufferedImage reassembledChunksImage = new BufferedImage(reassembled_chunks_image_width, reassembledChunksImageHeight, BufferedImage.TYPE_INT_RGB);    int indexOfTheChunkToUse = 0;    for(int i = 0; i < reassembled_chunks_image_width; i += rescaled_chunk_width) {        for(int j = 0; j < reassembledChunksImageHeight; j += rescaledChunkHeight) {            final BufferedImage chunkToUse = theChunks.get(indexOfTheChunkToUse);            int iForDraw = i;            int jForDraw = j;            final int deltaI = reassembled_chunks_image_width - (i + rescaled_chunk_width);            final int deltaJ = reassembledChunksImageHeight - (j + rescaledChunkHeight);            if(deltaI < 0) {                iForDraw -= Math.abs(deltaI);            }我瀏覽重新縮放的圖像,用塊的足夠(x 軸或 y 軸)尺寸(所有塊具有相同的尺寸)增加水平或垂直移位。相關(guān)循環(huán)是:for(int i = 0; i < reassembled_chunks_image_width; i += rescaled_chunk_width) {for(int j = 0; j < reassembledChunksImageHeight; j += rescaledChunkHeight) {我將當(dāng)前重新縮放圖像的像素顏色設(shè)置為當(dāng)前塊的顏色之一。相關(guān)循環(huán)是:for(int x = 0; x < rescaled_chunk_width; x++) {for(int y = 0; y < rescaledChunkHeight; y++) {.如果當(dāng)前塊超出了重新縮放圖像的范圍,我會(huì)將其移動(dòng)到左側(cè)或頂部,然后繪制它。相關(guān)控件是:if(deltaI < 0) {if(deltaJ < 0) {.
查看完整描述

1 回答

?
Cats萌萌

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超9個(gè)贊

你可以嘗試重構(gòu)你的方法,例如


int iForDraw = getDraw(reassembled_chunks_image_width, rescaled_chunk_width, i);

int jForDraw = getDraw(reassembledChunksImageHeight, rescaledChunkHeight, j);

添加一個(gè)小方法,例如 getDraw


private int getDraw(int reassembled_chunks_image_data, int rescaled_chunk_data, int index) {

    int result = index;

    int delta = reassembled_chunks_image_data - (index + rescaled_chunk_data);

    if (delta < 0) {

        result -= Math.abs(delta);

    }

    return result;

}


查看完整回答
反對(duì) 回復(fù) 2023-09-13
  • 1 回答
  • 0 關(guān)注
  • 96 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)