Skip to content

Commit

Permalink
test4
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbegin committed Oct 31, 2018
1 parent 88d4c28 commit 524c7fa
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions modules/view/backends/windows/draw.reds
Expand Up @@ -1379,6 +1379,25 @@ free-dc: func [
DeleteDC dc
]

premul-pixel: func [
pixel [int-ptr!]
alpha [integer!]
/local
a [integer!]
r [integer!]
g [integer!]
b [integer!]
][
a: alpha
r: (pixel/1 >>> 16) and 255
g: (pixel/1 >>> 8) and 255
b: pixel/1 and 255
r: r * alpha / 255
g: g * alpha / 255
b: b * alpha / 255
pixel/1: (a << 24) or (r << 16) or (g << 8) or b
]

create-blur-bitmap: func [
gfx [integer!]
bmp [integer!]
Expand All @@ -1392,13 +1411,9 @@ create-blur-bitmap: func [
rgb [integer!]
alpha [byte-ptr!]
gbmp1 [integer!]
gbmp2 [integer!]
bmp1 [BitmapData!]
bmp2 [BitmapData!]
scan1 [int-ptr!]
end1 [int-ptr!]
scan2 [int-ptr!]
end2 [int-ptr!]
p [byte-ptr!]
][
width: AlphaBoxBlur/GetWidth
Expand All @@ -1409,13 +1424,9 @@ create-blur-bitmap: func [
rgb: (to-gdiplus-color blur-color) and 00FFFFFFh

gbmp1: 0
gbmp2: 0
GdipCreateBitmapFromHBITMAP as handle! bmp 0 :gbmp1 ;-- can't get alpha channel
GdipCreateBitmapFromGraphics width height gfx :gbmp2 ;-- this create a empty bitmap
bmp1: as BitmapData! OS-image/lock-bitmap-fmt gbmp1 PixelFormat32bppARGB no
bmp2: as BitmapData! OS-image/lock-bitmap-fmt gbmp2 PixelFormat32bppARGB yes
;dump-rect bmp1/scan0 true width height dump-rect-radix
;dump-rect bmp2/scan0 true width height dump-rect-radix
scan1: as int-ptr! bmp1/scan0
end1: scan1 + size
p: alpha
Expand All @@ -1426,24 +1437,21 @@ create-blur-bitmap: func [
]

AlphaBoxBlur/blur alpha

scan1: as int-ptr! bmp1/scan0
end1: scan1 + size
scan2: as int-ptr! bmp2/scan0
end2: scan2 + size
p: alpha
while [scan2 < end2][
scan2/value: rgb or ((as integer! p/1) << 24)
while [scan1 < end1][
;scan1/value: rgb or ((as integer! p/1) << 24)
premul-pixel scan1 as integer! p/1
p: p + 1
scan1: scan1 + 1
scan2: scan2 + 1
]
;dump-rect bmp2/scan0 true width height dump-rect-radix
dump-rect bmp1/scan0 true width height dump-rect-radix
OS-image/unlock-bitmap-fmt gbmp1 as-integer bmp1
OS-image/unlock-bitmap-fmt gbmp2 as-integer bmp2

free alpha
GdipDisposeImage gbmp1
gbmp2
gbmp1
]

shadow-left: 5
Expand All @@ -1470,7 +1478,6 @@ draw-outset-shadow: func [
gfx [integer!]
dc [handle!]
gbmp1 [integer!]
gbmp2 [integer!]
ftn [integer!]
bf [tagBLENDFUNCTION]
][
Expand Down Expand Up @@ -1504,20 +1511,19 @@ draw-outset-shadow: func [
bottom - top - 1
rad
shadow-color and 00FFFFFFh ;-- core rect region alpha = 255
;gbmp1: GdipCreateBitmapFromHBITMAP as handle! bmp 0 :gbmp1
gbmp2: create-blur-bitmap gfx bmp shadow-color
GdipDrawImageRectI gfx gbmp2 0 0 width height
GdipDisposeImage gbmp2
gbmp1: create-blur-bitmap gfx bmp shadow-color
GdipDrawImageRectI gfx gbmp1 0 0 width height
GdipDisposeImage gbmp1

;BitBlt ctx/dc left + shadow-left top + shadow-top width height dc 0 0 SRCCOPY

;ftn: 0
;bf: as tagBLENDFUNCTION :ftn
;bf/BlendOp: as-byte 0
;bf/BlendFlags: as-byte 0
;bf/SourceConstantAlpha: as-byte 255
;bf/AlphaFormat: as-byte 1
;AlphaBlend ctx/dc left + shadow-left top + shadow-top width height dc 0 0 width height ftn
ftn: 0
bf: as tagBLENDFUNCTION :ftn
bf/BlendOp: as-byte 0
bf/BlendFlags: as-byte 0
bf/SourceConstantAlpha: as-byte 255
bf/AlphaFormat: as-byte 1
AlphaBlend ctx/dc left + shadow-left top + shadow-top width height dc 0 0 width height ftn

;bitmap-mix

Expand Down

0 comments on commit 524c7fa

Please sign in to comment.