woong's

Image 그림자 효과 주기 본문

Develop/Android

Image 그림자 효과 주기

dlsdnd345 2016. 2. 14. 16:09
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Image 그림자 효과 주기


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    private static Bitmap getDropShadow(Bitmap bitmap) {
 
        if (bitmap == null)
            return null;
        int think = 15;
        int w = bitmap.getWidth();
        int h = bitmap.getHeight();
 
        int newW = w - (think);
        int newH = h - (think);
 
        Bitmap.Config conf = Bitmap.Config.ARGB_8888;
        Bitmap bmp = Bitmap.createBitmap(w, h, conf);
        Bitmap sbmp = Bitmap.createScaledBitmap(bitmap, newW, newH, false);
 
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        Canvas c = new Canvas(bmp);
 
        // Right
        Shader rshader = new LinearGradient(newW, 0, w, 0, Color.GRAY, Color.LTGRAY, Shader.TileMode.CLAMP);
        paint.setShader(rshader);
        c.drawRect(newW, think, w, newH, paint);
 
        // Bottom
        Shader bshader = new LinearGradient(0, newH, 0, h, Color.GRAY, Color.LTGRAY, Shader.TileMode.CLAMP);
        paint.setShader(bshader);
        c.drawRect(think, newH, newW, h, paint);
 
        //Corner
        Shader cchader = new LinearGradient(0, newH, 0, h, Color.LTGRAY, Color.LTGRAY, Shader.TileMode.CLAMP);
        paint.setShader(cchader);
        c.drawRect(newW, newH, w, h, paint);
 
        c.drawBitmap(sbmp, 0, 0, null);
 
        return bmp;
    }



 



이와 같이 이미지 뒤에 그림자를 만들수 있다.


Comments