Settings | Sign in | Sign up

There are currently 3 posts.

【Flash AS】更改圖片色調

Floor 1 产品的注销 1/9/11 21:38
import flash.filters.BitmapFilter;//d導入圖像濾鏡效果 
import flash.filters.ColorMatrixFilter;//導入顏色矩陣濾鏡 

this.createEmptyMovieClip("yourMc",this.getNextHighestDepth());//創建用來載入圖片的電影剪輯 

function loadSwf(holder:MovieClip) { 
holder.loadMovie("your.jpg"); 
var matrix:Array = new Array(); 
matrix = matrix.concat([1, 0, 0, 0, 0]);// red 
matrix = matrix.concat([0, 1, 0, 0, 0]);// green 
matrix = matrix.concat([0, 0, 1, 0, 0]);// blue 
matrix = matrix.concat([0, 0, 0, 1, 0]);// alpha 
var filter:BitmapFilter = new ColorMatrixFilter(matrix); 
holder.filters = new Array(filter); 
} 
loadSwf(yourMc); 


調整顏色: 
第一行的值決定了紅色值,第二行決定綠色,第三行藍色,第四行是透明(Alpha)通道值。同樣可以看出首四欄值是與紅,綠,藍,alpha通道值的乘積,而第五欄的值分別是和(偏移量)。注意每行的源值和結果值都是在0到255的區間內。因此即使各個通道的值小於0或大於255都會被強制到該區間內。我來舉些例子說明它的原理 


調試效果參考:http://www.adobe.com/devnet/flash/articles/matrix_transformations/ColorMatrixDemo.swf
參考資料:http://bbs.blueidea.com/thread-2660633-1-1.html 
Floor 2 产品的注销 1/9/11 21:39
這個很好辦啊,
mc.loadMovie("風光2.jpg")
以上代碼你應該熟悉吧。
調整導入的風光2.jpg文件的色調,只要調整裝載這個swf文件的元件,即mc的色調就行了。

具體:就是先新建一個空mc,拖到舞台合適位置,起個實例名:mc,然後在時間軸加以上腳本。
改變色調,就是在屬性面板中改變mc的色調就可以了。

不用屬性面板,那就新建一個color對象來調整了。具體語句請參照腳本幫助里的color對象。
Floor 3 产品的注销 1/9/11 21:39

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
©2010-2025 Purasbar Ver3.0 [Mobile] [Desktop]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported license.