|
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
1. Create a shadow around an image #4220 Posted by: dgnoyon 2004-05-25 00:34:39 |
I would like create a shadow around an control (like QIMAGE or QEDIT or...) How can I implement this on rapidq ? Thank you in advance
|
2. Re: Create a shadow around an image #4224 Posted by: dgnoyon 2004-05-26 01:06:49 |
OK i find a VB code but I don't know how convert him because it use "Control" IF someone can help me to convert him Thank you
--------------------------------------------------- Attribute VB_Name = "Module1" Global Const GFM_STANDARD = 0 Global Const GFM_RAISED = 1 Global Const GFM_SUNKEN = 2 Global Const GFM_BACKSHADOW = 1 Global Const GFM_DROPSHADOW = 2 Global Const BOX_WHITE& = &HFFFFFF Global Const BOX_LIGHTGRAY& = &HC0C0C0 Global Const BOX_DARKGRAY& = &H808080 Global Const BOX_BLACK& = &H0& Public Sub ControlOmbre(MonForm As Form, C As Control, EffetOmb As Integer, LargeurOmb As Integer, CouleurOmb As Long) Dim OmbreCouleur As Long Dim OmbreLargeur As Integer Dim AncienneLargeur As Integer Dim AncienneTaille As Integer
OmbreLargeur = LargeurOmb OmbreCouleur = CouleurOmb AncienneLargeur = MonForm.DrawWidth AncienneTaille = MonForm.ScaleMode MonForm.ScaleMode = 3 MonForm.DrawWidth = 1 Select Case EffetOmb Case GFM_DROPSHADOW MonForm.Line (C.Left + OmbreLargeur, C.Top + OmbreLargeur)-Step(C.Width - 1, C.Height - 1), OmbreCouleur, BF Case GFM_BACKSHADOW MonForm.Line (C.Left - OmbreLargeur, C.Top - OmbreLargeur)-Step(C.Width - 1, C.Height - 1), OmbreCouleur, BF End Select
MonForm.DrawWidth = AncienneLargeur MonForm.ScaleMode = AncienneTaille End Sub ----------------------------------------------------------------- |
3. Re: Create a shadow around an image #4228 Posted by: 2004-05-26 06:08:44 |
Put the control(s) atop a QCanvas and in that background image put a filled rectangle? As long as you do not put anything in the QCanvas it will be invisible so it shouldn't interfere with other elements.
One sucky problem is that erasing said "shadow" means clearing it with the windows background color; to get that color you need an API call;
put Declare Function GetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long at the very start of your program, then use
Bckgrnd = GetSysColor(COLOR_3DFACE)
to put the background color Windows is using into the variable Bckgrnd, use that variable to "unpaint" the "shadow".
As you know the Windows colors can be changed so you need to read the current color. Now the suckyness comes from the fact that the color you thus get sometimes does not actually match the windows color!
|
4. Re: Create a shadow around an image #4237 Posted by: dgnoyon 2004-05-26 15:45:54 |
Hi Baardaap, I anderstand your explanation concerning the black rectangle... but i don't anderstand the 'unpaint'... In the same time, I would like, if it's possible, create a shadow with pixel not with rectangle. A rectangle is a regular form and not totaly a 'real' shadow
I find for example an other source VB which create a DLL see the link : www.vbfrance.com/dlzip.zipnix?ID=1966 It create a shadow with different pixel color ....
Denis
|
5. Re: Create a shadow around an image #4238 Posted by: 2004-05-26 16:39:41 |
a rectangle is just the simplest 'shadow' you can do. It does not have to be black of course (in fact it would be better to take the Windows background color and make a darker version of that color to use for the shadow).
On that subject; the color is an RGB value which you can split up with
blue = int(bckgrnd/(256*256)) green = int(bckgrnd/256) - klblauw*256 red = bckgrnd - klgroen*256 - klblauw*256*256
So to make a shadow just substract an amount from each color (the more you substract the darker the shadow) and add the color parts together;
shadow = red + green * 256 + blue * 256 * 256
By "unpainting" I meant that if you remove the thing you make a shadow of that you then should remove the "shadow" of it.For that you need (as per the previous post) the Windows form background color
|
6. Re: Create a shadow around an image #4239 Posted by: dgnoyon 2004-05-26 17:50:33 |
OK, thank you for your answer and I anderstand all... but, if my shadow is on a picture, it is necessary to take each pixel from background and add color... it could take a long time to do this ?
2 Cases : - we have a background with 1 color : I take one pixel and calculate the shadow color for all my control
- we have a picture on background (more than 1 color) : I take each pixel and calculate the shadow color for all my control
Have we a solution ?
|
7. Re: Create a shadow around an image #4240 Posted by: 2004-05-26 18:09:19 |
the normal Rapid Q elements are all rectangular so creating a shadow for them would just be a rectangle (possibly with a triangular area in the two edges).
Creating a shadow for a picture is best done in a graphics proggy, then use the image file in Rapid Q. You can do a real shadow in Rapid Q but it would be difficult and take rather long.
Go to www.irfanview.com to get the freeware tool IrfanView, get the pic you want a shadow for and use irfan to change the color of the pic (darken it), then save it under a different name. Open THAT pic in Paint and then put the original picture on top of it but shifted so you get a shadow under it.
The best thing about Rapid Q is that you can include an image in the program Rapid Q produces by using $Resource. An example;
$RESOURCE ima as "shady.bmp" shade.BMPhandle = steen0 Dim Image AS QCanvas Image.Height = 370 Image.Width = 680 Image.Left = 100 Image.Top = 2 Image.OnPaint = Image.Paint Image.Parent = Form
SUB Image.Paint Image.draw (1,1,shade.BMP) END SUB
You need the OnPaint because when you move anything over an image in a Rapid Q window the image gets overwritten, the OnPaint restores it.
By using the image as a Resource it gets included in the executable (just like the program icon basically) so you do not need to distribute a bunch of files :) and to reduce file size use Irfan to lower the image file size beforehand (resize it and set the number of colors the image uses to a minimum - preferrably after using a median filter). You will rarely need a 24 bit color picture, 256 colors (Irfan redefines the palette) normally suffice and mean a reduction of the image file size by 2/3rds. |
8. Re: Create a shadow around an image #4241 Posted by: 2004-05-26 18:13:03 |
if you mean putting a control on top of an image and creating a shadow for that control I'd do the same thing basically; take the original image into IrfanView and darken it, then go into Paint and cut out a section in the shape of the control element and its shadow, then paste that cutout on to the original image to create the shadow. By making the cutout include the control element aligning the control element on the picture is easier to do. |
9. Re: Create a shadow around an image #4242 Posted by: dgnoyon 2004-05-26 18:15:51 |
ok thank you for your interest |
10. Re: Create a shadow around an image #4243 Posted by: 2004-05-26 18:16:01 |
look at http://s7.invisionfree.com/DoBasic/index.php?showtopic=12 for a shadow to a control method, a basic rectangular shadow. |
11. Using QRichEdit in UDTs #4580 Posted by: 2004-06-22 22:38:18 |
Could anybody solve this prob for me. please? I'm writing a prog in which I'd like to use UDTs that store STRINGs but QEdit's one-line approach isn't good enough and I don't know how to use QRichEdit to grab the "STRING". Just in case you're wondering, I've not been using RapidQ for very long (about a month, I think), and I've managed to crack numerous other probs but this has got me stumped.
Just to exlpain, the prog (believe it or not) is a text adventure and I'd really like to store as much data in a single file as possible, such as long & short location descriptions and various location "flags".
Thanks in advance,
Steve S
|
12. Re: Create a shadow around an image #4800 Posted by: dgnoyon 2004-07-12 17:08:38 |
I show you a source code from VB translated by correodejordi2 I works fine and the result is very beautiful but SLOW :( If someone could see this code and optimize don't hesitate to do :)
I Think the best way is to use DIB API or color palette ....
http://g.slyip.com/f.php?f=16848 |
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |