corona 提供的图像处理--lua和android

Corona 提供了很多图像处理方法,今天研究了下,做个记录

直接上图,下面有代码

 

--
-- Abstract: Filter Demo sample app
--
-- Date: 3-13-2015
--
-- Version: 1.0
--
-- File name: main.lua
--
-- Author: siyuan Openpad Project
--
-- Demonstrates: graphics, shaders, filters
--
-- File dependencies: none
--
-- Target devices: Simulator and devices
--
-- Limitations: none
--
-- Update History: none
--
-- Comments: none
---------------------------------------------------------------------------------------
-- do start and fill screen
print("----Start Lua...")

CONSTANT_SCREEN_WIDTH = display.contentWidth
CONSTANT_SCREEN_HEIGHT = display.contentHeight


halfW = CONSTANT_SCREEN_WIDTH * 0.33
halfH = CONSTANT_SCREEN_HEIGHT * 0.33
offectW =  halfW * 0.5
offectH =  halfH * 0.5

local group = display.newGroup()

print("----Screen w = "..CONSTANT_SCREEN_WIDTH.."\t h = "..CONSTANT_SCREEN_WIDTH)


function  drawImage( )
    -- for j=1,9 do
    --     local image = display.newImageRect( "colmdog.jpg", halfW, halfH)
    --     group:insert( image )
    -- end    
    
    -- group[1]:translate(offectW, offectH)    
    -- group[2]:translate(offectW * 3, offectH)
    -- group[3]:translate(offectW * 5, offectH)

    -- group[4]:translate(offectW, offectH * 3)    
    -- group[5]:translate(offectW * 3, offectH * 3)
    -- group[6]:translate(offectW * 5, offectH * 3)

    -- group[7]:translate(offectW, offectH * 5)    
    -- group[8]:translate(offectW * 3, offectH * 5)
    -- group[9]:translate(offectW * 5, offectH * 5)

    for i = 1,3 do
        for j = 1,3 do
            local image = display.newImageRect( "colmdog.jpg", halfW, halfH)
            local translateX,translateY
            image:translate(offectW * (2 * j - 1), offectH * (2 * i - 1))
            group:insert( image )
        end
    end
end

function doEffects()
    --group[1] is orignal
    group[1].fill.effect = "filter.saturate"
    group[1].fill.effect.intensity = 4

    group[2].fill.effect = "filter.bloom"
    group[2].fill.effect.levels.white = 0.8
    group[2].fill.effect.levels.black = 0.4
    group[2].fill.effect.levels.gamma = 1
    group[2].fill.effect.add.alpha = 0.8
    group[2].fill.effect.blur.horizontal.blurSize = 20
    group[2].fill.effect.blur.horizontal.sigma = 140
    group[2].fill.effect.blur.vertical.blurSize = 20
    group[2].fill.effect.blur.vertical.sigma = 240
    
    group[3].fill.effect = "filter.blurVertical"
    group[3].fill.effect.blurSize = 20
    group[3].fill.effect.sigma = 140        

    group[4].fill.effect = "filter.brightness"
    group[4].fill.effect.intensity = 0.4

    group[5].fill.effect = "filter.blurGaussian"
    group[5].fill.effect.horizontal.blurSize = 20
    group[5].fill.effect.horizontal.sigma = 140
    group[5].fill.effect.vertical.blurSize = 20
    group[5].fill.effect.vertical.sigma = 140

    group[6].fill.effect = "filter.bulge"
    group[6].fill.effect.intensity = 1.8

    group[7].fill.effect = "filter.grayscale"

    group[8].fill.effect = "filter.colorChannelOffset"
    group[8].fill.effect.xTexels = 8
    group[8].fill.effect.yTexels = 8

    group[9].fill.effect = "filter.emboss"
    group[9].fill.effect.intensity = 0.2
end


drawImage()
doEffects()

-- do end 
print("----End of Lua...")

 

转载于:https://www.cnblogs.com/LiuSiyuan/p/4335379.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值