2017-10-19 281 views
1

有人可以幫助我有這種透明背景顏色的前景圖像。我應該使用透明圖像的多個過濾器或如何實現這一目標,我可以通過#AARRGGBB值獲得透明度,但不是像下圖所示的紋理。透明背景與顏色的前景圖像

我現在使用相同的前景圖像和相同的背景圖像我想介紹這兩個之間的過濾器,以便只有圖像的顏色可見,而不是圖像本身。我想知道在這兩幅圖像之間應該使用透明濾鏡的值(ARGB)來實現這一點,還是有其他方法。

enter image description hereenter image description hereenter image description here

+0

讓我們看看一些代碼。我不確定你想要做什麼。你試過了什麼代碼? – happymacarts

+0

@happymacarts與代碼無關,在我的用戶界面我使用透明背景作爲#AA-00-00-00與alpha通道爲50%透明,這使得它#80-00-00-00讓我的可見的背景圖像我只想要前景圖像的顏色可見而不是前景圖像本身。 –

+0

好吧,因爲這與代碼無關,因此可能不是發佈問題的正確位置。如果我在photoshop標籤下回答這個問題,我可能會說只是眼睛的顏色,並創建一個面具。它看起來更像是一個BLUR而不是一個rgba填充 – happymacarts

回答

2

也許,你正在尋找Palette

這是一個輔助類,從圖像中提取突出的顏色。

  • 活力
  • 活力黑暗
  • 活力光
  • 靜音
  • 靜音黑暗
  • 靜音光
:甲 數目的具有不同輪廓的顏色從圖像中提取

在這裏,你如何使用它。

// Synchronous 
Palette p = Palette.from(bitmap).generate(); 

// Asynchronous 
Palette.from(bitmap).generate(new PaletteAsyncListener() { 
    public void onGenerated(Palette p) { 
     // Use generated instance 
    } 
}); 

而且以檢索顏色,

p.getVibrantColor(int defaultColor) //return int of RGB 

然而,Pallete回報只有一種顏色,沒有漸變因爲你已經在這個問題的圖像顯示。對我來說,他們似乎已經模糊了,並增加了前景圖像的透明度,然後將其發佈到後臺。

1

這裏有一個簡單的解決方案,可以實現你在找什麼只是用CSS無需插件

.wrapper { 
 
    position: relative; 
 
    width: 300px; 
 
    height: 400px; 
 
    text-align:right; 
 
} 
 
.wrapper div { 
 
    background-image: url("http://www.placecage.com/c/200/300"); 
 
    background-repeat: no-repeat; 
 
    background-size: 100%; 
 
} 
 
.blur { 
 
    -webkit-filter: blur(12px); 
 
    -ms-filter: blur(12px); 
 
    filter: blur(12px); 
 
    width: 100%; 
 
    height: 100%; 
 
    z-index: -10; /* place below other items*/ 
 
} 
 
.focus { 
 
    z-index: 999;/* make sure to place at a high z-index so it shows up on top*/ 
 
    border: 1px solid white; 
 
    position: absolute; 
 
    top: 25%; 
 
    left: 25%; 
 
    width: 50%; 
 
    height: 50%; 
 
}
<div class="wrapper"> 
 
    <div class="blur"></div> 
 
    <div class="focus"></div> 
 
    <a href="https://www.placecage.com/">Place Cage </a> 
 
</div>

1

原來,有幾個簡單的選項,使用android上實現這一目標像開發人員稱爲wasabeef的BlurryPicasso transformations這樣的庫。如果您已經在項目中使用畢加索圖像庫,那麼我會使用picasso轉換,因爲它與picasso圖像庫無縫集成。我所做的只是提到了這種情況下我想要的轉換類型,它是一種模糊的轉換,並給出可選的半徑和採樣率。

  Picasso 
      .with(imageView.getContext()) 
      .load(imgUrl) 
      .transform(new BlurTransformation(imageView.getContext(),10,8)) 
      .fit() 
      .placeholder(placeHolder) 
      .error(error) 
      .into(imageView);