November 28, 2020, 02:28:20 AM

### Author Topic: [bb] Emboss by Vertex [ 1+ years ago ]  (Read 567 times)

#### BlitzBot

• Jr. Member
• Posts: 1
##### [bb] Emboss by Vertex [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Emboss
Author : Vertex
Posted : 1+ years ago

Description : Hi!
Hmmm yes a little emboss-effect
cu olli

Code :
Code: BlitzBasic
1. ; ------------------------------------------------------------
2.   Graphics 640,480,32,2
3.   SetBuffer BackBuffer()
4. ; ------------------------------------------------------------
5.
6. ; ------------------------------------------------------------
7.   Image = CreateImage(400,300)
8.   Dim Buffer(ImageWidth(Image),ImageHeight(Image))
9.   Dim Picture(ImageWidth(Image),ImageHeight(Image))
10. ; ------------------------------------------------------------
11.
12. ; ------------------------------------------------------------
13.   SetBuffer ImageBuffer(Image)
15.   SetFont Font
16.   Text 200,150,"BlitzBASIC",1,1
17. ; ------------------------------------------------------------
18.
19. ; ------------------------------------------------------------
20.   LockBuffer ImageBuffer(Image)
21.
22.   For X = 0 To ImageWidth(Image)
23.      For Y = 0 To ImageHeight(Image)
25.      Next
26.   Next
27.
28.   For X = 0 To ImageWidth(Image) - 3
29.      For Y = 0 To ImageHeight(Image) - 1
30.         BufferR1 = GetR(Buffer(X,Y))
31.         BufferG1 = GetG(Buffer(X,Y))
32.         BufferB1 = GetB(Buffer(X,Y))
33.
34.         BufferR2 = GetR(Buffer(X + 3,Y + 1))
35.         BufferG2 = GetG(Buffer(X + 3,Y + 1))
36.         BufferB2 = GetB(Buffer(X + 3,Y + 1))
37.
38.         TempR = Abs(BufferR1) - BufferR2 + 128
39.         If TempR > 255 Then TempR = 255
40.         If TempR < 0   Then TempR = 0
41.
42.         TempG = Abs(BufferG1) - BufferG2 + 128
43.         If TempG > 255 Then TempG = 255
44.         If TempG < 0   Then TempG = 0
45.
46.         TempB = Abs(BufferB1) - BufferB2 + 128
47.         If TempB > 255 Then TempB = 255
48.         If TempB < 0   Then TempB = 0
49.
50.           Picture(X,Y) = GetRGB(TempR,TempG,TempB)
51.      Next
52.   Next
53.
54.   For X = 0 To ImageWidth(Image) - 3
55.      For Y = 0 To ImageHeight(Image) - 1
56.         WritePixelFast X,Y,Picture(X,Y)
57.      Next
58.   Next
59.
60.   For X = ImageWidth(Image) - 3 To ImageWidth(Image)
61.      For Y = ImageHeight(Image) - 1 To ImageHeight(Image)
62.           WritePixelFast X,Y,Buffer(X,Y)
63.      Next
64.   Next
65.   UnlockBuffer ImageBuffer(Image)
66. ; ------------------------------------------------------------
67.
68. ; ------------------------------------------------------------
69.   Dim Buffer(0,0)
70.   Dim Picture(0,0)
71. ; ------------------------------------------------------------
72.
73. ; ------------------------------------------------------------
74.   SetBuffer BackBuffer()
75.   DrawImage Image,0,0 : Flip
76. ; ------------------------------------------------------------
77.
78. ; ------------------------------------------------------------
79.   WaitKey : FreeImage Image : End
80. ; ------------------------------------------------------------
81.
82. ; ------------------------------------------------------------
83.   Function GetR(RGB)
84.      Return (RGB And \$FF0000) / \$10000
85.   End Function
86.
87.   Function GetG(RGB)
88.      Return (RGB And \$FF00) / \$100
89.   End Function
90.
91.   Function GetB(RGB)
92.        Return RGB And \$FF
93.   End Function
94.
95.   Function GetRGB(R,G,B)
96.      Return R * \$10000 + G * \$100 + B
97.   End Function
98. ; ------------------------------------------------------------