Yay :grin:
Posted on 2002-10-21 11:06:15 by Qweerdy
prettyyyyyyyyyyyyyyyyy
Posted on 2002-10-21 18:57:35 by illwill
Is blind.asm can aplha under 9x,
:alright:
Posted on 2002-10-21 20:15:11 by Const.Ex
Actually, the thing I was so happy about is the text output and clipping :) At first I painted it directly onto the window's main bitmap, but that wasn't very efficient when you have many texts moving around. So I chose to have a separate bitmap for each control; unfortunately cleartype really screwed up the pretty text :( But now it works :)

And... ehm... no it doesn't work on win98 :( At least not the alpha transparency of the main window's background.
Posted on 2002-10-23 07:07:10 by Qweerdy
I few of the pixels around the buttons look 'off'? I think
a better algo is needed for the blend function.
Posted on 2002-10-23 09:26:03 by bitRAKE
Perhaps... you're welcome to code some improvements of course :) The old test proggie should still work for testing the algo, since the same operation are still done on the scrollbar images. Right now this is what I have for painting the window:

0. Child control is operated so its appearance needs to change.
1. Child control sends WM_PAINT to itself with fRedraw flag set
2. Child redraws itself (onto its own bitmap)
3. Child enumerates its children and sends them a WM_PAINT. They then paint their bitmaps onto the parent's bitmap (see step 8).
4. Child sends its parent a WM_PAINT
5. Main window gets a WM_PAINT
6. Paint window background onto backbuffer using PaintSkin
7. Enumerate child windows, send WM_PAINT to each
8. Most well-behaved child controls should just call DefaultPaint to AlphaBlend their bitmap onto their parent.
9. Flip backbuffer and front buffer

The scrollbar control paints its appearance using my own SimpleBlt function, which just copies a bitmap block (BitBlt needs a DC and doesn't preserve the alpha byte). The complete bitmap is then AlphaBlend'ed onto the main window, so you see the output shouldn't be different from the simple test program.
Posted on 2002-10-24 02:52:42 by Qweerdy
I'll change the algo to implement the following:
top pixel       = (Rt, Gt, Bt, At)

bottom pixel = (Rb, Gb, Bb, Ab)
composite pixel = (Rc, Gc, Bc, Ac)

all values in the range 0..1

Ac = 1 - (1 - At)(1 ? Ab)
s = At / Ac
t = (1 - At) Ab / Ac
Rc = s Rt + t Rb
Gc = s Gt + t Gb
Bc = s Bt + t Bb
http://graphics.stanford.edu/courses/cs248-02/
http://graphics.stanford.edu/courses/cs248-02/blinn_theory.pdf
Posted on 2002-11-08 16:33:27 by bitRAKE
I have fixed the problem (see attached picture). The good one is on the top - notice the darkened edge of the bottom one. I'll post the code after it is converted to MMX.
Posted on 2002-11-09 14:32:44 by bitRAKE
Here is the MMX/MMX+ code. In addition to this code, all bitmaps passed to this proceedure need to have their alphas pre-multiplied -- now you can see why windows likes pre-multiplied alphas (easier code, but less accuracy).
CompositeBlend proc USES ebx esi edi, hSrcBm:DWORD,srcx:DWORD,srcy:DWORD,srcw:DWORD,srch:DWORD,hDstBm:DWORD,dstx:DWORD,dsty:DWORD

LOCAL bmsrc:BITMAP
LOCAL bmdst:BITMAP

invoke GetObject,hSrcBm,sizeof bmsrc,addr bmsrc
invoke GetObject,hDstBm,sizeof bmdst,addr bmdst

mov edx, bmdst.bmHeight
mov eax, bmdst.bmWidth
sub edx, srch
mov edi, bmdst.bmBits
sub edx, dsty
mul edx
add eax, dstx
lea edi, [edi + eax*4]

mov edx, bmsrc.bmHeight
mov eax, bmsrc.bmWidth
sub edx, srch
mov esi, bmsrc.bmBits
sub edx, srcy
mul edx
add eax, srcx
lea esi, [esi + eax*4]

shr srcw, 1
dec srcw
shl bmsrc.bmWidth, 2
shl bmdst.bmWidth, 2

Top EQU <esi + ecx*8>
Bottom EQU <edi + ecx*8>
Destination EQU <Bottom>

pxor mm7, mm7
pcmpeqd mm6, mm6

; -- PreMultiplied Alpha --
; H = result color (y, yr, yg, yb)
; F = top color (a, ar, ag, ab)
; G = bottom color (b, br, bg, bb)
;
; Composite: H = (1-b)F + G

BlendLoop:
mov ecx, srcw

IFDEF __MMX_PLUS__

_0: movq mm1, [Bottom] ; 8 bits per component
movq mm0, [Top]
movq mm2, mm1
punpcklbw mm1, mm7
punpckhbw mm2, mm7
pshufw mm4, mm0, 11111111y
pshufw mm5, mm0, 01010101y
pxor mm4, mm6
pxor mm5, mm6
pmulhuw mm1, mm4
pmulhuw mm2, mm5
packuswb mm2, mm1
paddusb mm2, mm0
movq [Destination], mm2
ELSE

_0: movq mm1, [Bottom] ; 8 bits per component
movq mm0, [Top]
movq mm2, mm1

punpcklbw mm1, mm7
punpckhbw mm2, mm7

movq mm4, mm0
pxor mm4, mm6
psrlw mm4, 8
movq mm5, mm4

punpcklwd mm4, mm4
punpckhwd mm5, mm5
punpckhdq mm4, mm4
punpckhdq mm5, mm5

pmullw mm1, mm4
pmullw mm2, mm5

psrlw mm1, 8
psrlw mm2, 8

packuswb mm1, mm2
paddusb mm1, mm0

movq [Destination], mm1
ENDIF
dec ecx
jns _0

add esi, bmsrc.bmWidth
add edi, bmdst.bmWidth
dec srch
jnz BlendLoop

ret
CompositeBlend endp
Funny thing, if we move to 16 bits per channel the code reduces to:
	movq		mm0, [Top]		; 16 bits per component

movq mm1, [Bottom]

pshufw mm2, mm0, 11111111y
pxor mm2, mxc(<FFFF>) ; 1 - b

pmulhuw mm1, mm2
paddusw mm1, mm0

movq [Destination], mm1
!! But then we are moving around twice as much data.

p.s. Qweerdy, your box is full. ;)
This is to replace AlphaBlend2.
Posted on 2002-11-11 02:32:49 by bitRAKE
Qweerdy, your box is full

Yes, sorry about that.

Thanks for the finished algo, now I only have to fix a bug I have recently created in my program :) Forgot the first rule of programming: if it works, DON'T TOUCH IT!
Posted on 2002-11-11 10:55:49 by Qweerdy
thats a very nice work Qweerdy.
But do we get the source too?
Posted on 2002-11-15 21:51:05 by clippy
Qweerdy originally posted in ( THIS ) thread - the code is at his website. I've heard he is working on an update with many more features, but he is very busy with school.
Posted on 2002-11-16 00:19:05 by bitRAKE
Ok i checked out the demo at his site. Nice, I must say :)
But the version on his site doesnt seem to match the one he has posted here in this thread.
Posted on 2002-11-16 01:27:30 by clippy
Let me explain about this thread a little...

This was originally posted in the Test area because I was very happy that I finally had text output working properly again. bitRAKE then used his evil moderator powers to hijack this thread and move it to the Algorithms forum :)
This may have given some people the idea that the program as it is seen in the screenshot is ready for release, while it was really a very early test version. I'm reasonably close to "finishing" the program, and when it is done I'll post the sourcecode on my website, and of course I'll let you all know by posting here too.
The finished program looks much better than the first versions, and features... ah what the hell, I'll just post a screenshot :)

The window caption is a LayeredLabel control, the listbox is a LayeredListbox with a child LayeredScrollbar control. Notice the text fades in and out at the top and bottom. Text output is still not as pretty as I'd like, but I thought I'd let the people on the board play with that a little.
Posted on 2002-11-16 02:35:16 by Qweerdy

This was originally posted in the Test area because I was very happy that I finally had text output working properly again. bitRAKE then used his evil moderator powers to hijack this thread and move it to the Algorithms forum :)
Yes, I am guilty. :tongue:

Thinking back, it would have been better just to post in the original PNGSkin thread, but we are going forward...

BTW, looks very good Qweerdy!
Posted on 2002-11-16 09:49:13 by bitRAKE
Amazing!!!!!!:eek:
Cant wait for the final version.
How about adding a small cross to the top of the window?
Posted on 2002-11-17 05:00:15 by clippy
I just uploaded PngSkin IV to my website http://www20.brinkster.com/qweerdy :cool:

If someone has any idea on how to improve the text output, please tell me!

(Oh, and you close the program by right-clicking on the window caption... forgot to mention that in the source :) )
Posted on 2002-11-17 10:49:20 by Qweerdy
Hi Qweerdy,
I tried compiling your pngskin but i seem to be missing the pnglib files. So could you please mail me the pnglib.lib and pnglib.inc files at gladiator34@rediffmail.com.

Also i notice you havent used the ColorizeSkin proc anywhere. My knowledge of asm being very asm (as u already know:) ) i cant make out most of it. So what does that proc actually do?

you close the program by right-clicking on the window caption

A little cross on the window would make it look more real (ie, more window-like).
Posted on 2002-11-22 11:21:19 by clippy
gladiator,

As Bazik might say, "Do you know what 'search' means?" :grin:
This thread will link you to Thomas's excellent PNGLIB.



Qweerdy,

As always, Very nice job! You rock. ;)
Posted on 2002-11-22 11:48:46 by iblis
gladiator,

The ColorizeSkin proc changes the hue (=color) of a skin. That can now be done with the ModifySkin proc, which also allows you to adjust the brightness, saturation and opacity. So you don't really need the ColorizeSkin proc any more.
I realize that I'm not using ModifySkin in the program either, but I didn't want to make it any more complex than it already is :)
As for closing it with a "X", I'll think about it... but I don't really want to make it behave exactly like a normal window.

iblis: Thanks :)
Posted on 2002-11-23 03:43:36 by Qweerdy