Hello all,

I'm just wondering whether it's possible to create a window region which has a smooth edge (anti aliased. I've attached a picture of the window 'skin' i have created, but as you can see it has nasty white border.

The region was created with Vander Nunes region creator, but I'm sure thats not the problem.. i fear it's just a limitaion of Win32.. ya have to live with the rough end of the pineapple so to speak !
Posted on 2002-08-02 17:48:09 by CodeBug
Design your skin so it has no aliasing problems with any background color? :P
Posted on 2002-08-02 17:53:50 by f0dder
f0dder :

Could you elaborate ?

I've attached the original bitmap (well JPG here for upload times). As you can see the edges of the shape are smooth.. are you suggesting i select a different 'transparancy' colour i.e. not white ?
Posted on 2002-08-02 18:00:47 by CodeBug
You can set the matte color on your graphics editor to transparent(If your graphics editor supports it).

Try this if it works.
Posted on 2002-08-02 18:24:12 by stryker
This will only be possible with a Windows version which supports layered windows, ie 2k & XP, maybe also ME I can't remember. :(

If you don't mind limiting to those OSs I'll post an example.
Posted on 2002-08-02 19:56:38 by Eóin
Yes, it is very possible. First, you need to get background image with GetDC(0). Then blit it to a device context created with CreateCompatibleDC, which has a bitmap selected on to it that is created with CreateDIBSection. Make sure you choose the pixel format suitable for your routines. After you have retrieved the background image, you will need alpha-blend routines that blend together your application image and the background image based on the alpha-mask. The alpha-mask will typically be complete white inside the actual window, gray on the edges and black on the outside of your image's background. White means only your application's image is put in the output (thus giving you a normal, solid look). Gray will mean both your application's background and the actual background behind the window are blended in together, giving you the anti-alias you wanted. Black, as you may have already guessed, means none of your application's image is needed and only the background behind it is used.
Posted on 2002-08-02 21:39:33 by comrade
the borders araound the edge are a slightly diffrent color then the transparancy backgraound color
Posted on 2002-08-02 22:13:29 by Qages
Afternoon, CodeBug.

One way is to make the backbround colour of your image middles-grey (128,128,128).
Another would be to create a "mask" image which you use for the region data. Have this mask one pixel smaller than the outline of your main image.

Cheers,
Scronty
Posted on 2002-08-03 03:26:01 by Scronty
The real trick is to make sure you do NOT do anti-aliasing in your graphics editor. After converting the image to 256color (assuming you use this mode), inspect the image closely - as Quages is indirectly saying, there's more than one shade of white.

I think comrades method would be awfully slow. Should work fine for a splash or whatever, but for a window that's being dragged around with "show window contents while dragging" enabled? :P
Posted on 2002-08-03 04:06:23 by f0dder

The real trick is to make sure you do NOT do anti-aliasing in your graphics editor. After converting the image to 256color (assuming you use this mode), inspect the image closely - as Quages is indirectly saying, there's more than one shade of white.



He he he... Occasionally get problems with that one on Paintbrush... sometimes I put a copy-pasted bmp part, have its background transparent, only to have a slightly-off shade of white wreck the effect. Oh well. One solution with pictures already made is to cut-and-paste on Paintbrush and see where the background is off-white (put a colored background on a new Paintbrush picture, then paste the picture to test with transparent on), then go back to the source picture to make off-white pixels pure white. JPG sources are even worse.
Posted on 2002-08-04 00:21:06 by AmkG
Thanks guys,

I've used a combination of all suggestions to get a 'perfect' result.

I still however believe the the win32 functions for creating standard elliptical or rounded-corner rectangles produced un-aliased regions. I think this is just a failing in win-bloze.

Cheers guys, no further help now required
Posted on 2002-08-04 05:42:22 by CodeBug
Failure, dunno... it requires "some" work to do antialiasing. GDI was designed before this became feasible... and with correctly designed bitmaps, you don't even need aliasing, so... :)
Posted on 2002-08-04 10:10:37 by f0dder