fading of two pictures (blend one picture into the other)
Author |
Message |
trenk.. #1 / 18
|
 fading of two pictures (blend one picture into the other)
hello, does anybody know how to fade one picture into another. or to blend between two pictures? is there a control or some sample code? ernst
|
Fri, 24 May 2002 03:00:00 GMT |
|
 |
Sheppe Phar #2 / 18
|
 fading of two pictures (blend one picture into the other)
Quote:
>hello, >does anybody know how to fade one picture into another. >or to blend between two pictures? >is there a control or some sample code? >ernst
I'm not sure if this is the kind of 'blending' you're looking for, but you can try it out. The code assumes there are two picture boxes on the form named Picture1 and Picture2, and that there are already pictures loaded in them. Option Explicit Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As _ Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _ ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As _ Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Private Const BLACKNESS = &H42 Private Const DSTINVERT = &H550009 Private Const MERGECOPY = &HC000CA Private Const MERGEPAINT = &HBB0226 Private Const NOTSRCCOPY = &H330008 Private Const NOTSRCERASE = &H1100A6 Private Const PATCOPY = &HF00021 Private Const PATINVERT = &H5A0049 Private Const PATPAINT = &HFB0A09 Private Const SRCAND = &H8800C6 Private Const SRCCOPY = &HCC0020 Private Const SRCERASE = &H440328 Private Const SRCINVERT = &H660046 Private Const SRCPAINT = &HEE0086 Private Const WHITENESS = &HFF0062 Private Sub Command1_Click() ' This example assumes that you have the scale mode set to ' pixels (vbPixels). ' A variable for containing the return value of the API ' function. Non-zero on success, zero on failure. Dim lngRetVal As Long ' Merge the image from Picture2 with the image from Picture1. lngRetVal = BitBlt(Picture1.hDC, 0, 0, Picture2.ScaleWidth, _ Picture2.ScaleHeight, Picture2.hDC, Picture2.ScaleLeft, _ Picture2.ScaleTop, MERGEPAINT) If lngRetVal = 0 Then MsgBox "Unable to copy source " _ & "to destination!", vbExclamation, "ATTENTION!" End Sub --- Sheppe Pharis, MCP * 3/Tekmetrics VB Certified VB5/VB6/VBA/VBS/ActiveX/API Developer
|
Sat, 25 May 2002 03:00:00 GMT |
|
 |
Tigran A #3 / 18
|
 fading of two pictures (blend one picture into the other)
I tried that source code and it really sucks. Does *anyone* know how to fade one picture into another, or just fade from a black screeen to your picture, or fade from a picture to a white screeen? Tigran Quote:
> >hello, > >does anybody know how to fade one picture into another. > >or to blend between two pictures? > >is there a control or some sample code? > >ernst > I'm not sure if this is the kind of 'blending' you're looking for, but > you can try it out. The code assumes there are two picture boxes on > the form named Picture1 and Picture2, and that there are already > pictures loaded in them. > Option Explicit > Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As _ > Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _ > ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As _ > Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long > Private Const BLACKNESS = &H42 > Private Const DSTINVERT = &H550009 > Private Const MERGECOPY = &HC000CA > Private Const MERGEPAINT = &HBB0226 > Private Const NOTSRCCOPY = &H330008 > Private Const NOTSRCERASE = &H1100A6 > Private Const PATCOPY = &HF00021 > Private Const PATINVERT = &H5A0049 > Private Const PATPAINT = &HFB0A09 > Private Const SRCAND = &H8800C6 > Private Const SRCCOPY = &HCC0020 > Private Const SRCERASE = &H440328 > Private Const SRCINVERT = &H660046 > Private Const SRCPAINT = &HEE0086 > Private Const WHITENESS = &HFF0062 > Private Sub Command1_Click() > ' This example assumes that you have the scale mode set to > ' pixels (vbPixels). > ' A variable for containing the return value of the API > ' function. Non-zero on success, zero on failure. > Dim lngRetVal As Long > ' Merge the image from Picture2 with the image from Picture1. > lngRetVal = BitBlt(Picture1.hDC, 0, 0, Picture2.ScaleWidth, _ > Picture2.ScaleHeight, Picture2.hDC, Picture2.ScaleLeft, _ > Picture2.ScaleTop, MERGEPAINT) > If lngRetVal = 0 Then MsgBox "Unable to copy source " _ > & "to destination!", vbExclamation, "ATTENTION!" > End Sub > --- > Sheppe Pharis, MCP * 3/Tekmetrics VB Certified > VB5/VB6/VBA/VBS/ActiveX/API Developer
|
Sat, 25 May 2002 03:00:00 GMT |
|
 |
Don Coo #4 / 18
|
 fading of two pictures (blend one picture into the other)
If this approach "sucks" ignore it : ) Place two picture boxes on your form. Load the desired pictures (same dimensions please) into each. Set the scale mode for both to "3 - pixel". Make the source picture's "visible" property = false and set its "auto redraw" property to true. Place a command buttomn on the screen and add the following code. Private Sub Command1_Click() maxy = Picture1.ScaleHeight maxx = Picture1.ScaleWidth n = 20 'vary this value for different effects For i = 0 To n For y = 0 To maxy Step n For x = 0 To maxx Picture1.PSet (x, y + i), Picture2.Point(x, y + i) Next x, y, i End Sub This will be slooooooooww but it give a nice effect. The source picture will "fade" into the destination -- not jump. I tried it on 200x200 pixel pictures and it took about a second to make the fade. Good Luck.
|
Sat, 25 May 2002 03:00:00 GMT |
|
 |
Jack Berli #5 / 18
|
 fading of two pictures (blend one picture into the other)
Hi, There was a company founded right there in Rochester that offered an incredible Active X to do that: FX Tools. Image FX is now a part of Pegasus, but FX Tools is still a very popular effects/display engine: http://www.*-*-*.com/ Educational discounts are offered, but it is a commercial program. Good luck, jack -- |-------------------------------------------------------------------------- ----| http://www.*-*-*.com/ ! Check out the Pegasus {*filter*} Tools: http://www.*-*-*.com/ {*filter*}/ |------------------------------------------------------------------------------| Quote:
> I tried that source code and it really sucks. > Does *anyone* know how to fade one picture into > another, or just fade from a black screeen to > your picture, or fade from a picture to a white > screeen? > Tigran
> > >hello, > > >does anybody know how to fade one picture into another. > > >or to blend between two pictures? > > >is there a control or some sample code? > > >ernst > > I'm not sure if this is the kind of 'blending' you're looking for, but > > you can try it out. The code assumes there are two picture boxes on > > the form named Picture1 and Picture2, and that there are already > > pictures loaded in them. > > Option Explicit > > Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As _ > > Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _ > > ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As _ > > Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long > > Private Const BLACKNESS = &H42 > > Private Const DSTINVERT = &H550009 > > Private Const MERGECOPY = &HC000CA > > Private Const MERGEPAINT = &HBB0226 > > Private Const NOTSRCCOPY = &H330008 > > Private Const NOTSRCERASE = &H1100A6 > > Private Const PATCOPY = &HF00021 > > Private Const PATINVERT = &H5A0049 > > Private Const PATPAINT = &HFB0A09 > > Private Const SRCAND = &H8800C6 > > Private Const SRCCOPY = &HCC0020 > > Private Const SRCERASE = &H440328 > > Private Const SRCINVERT = &H660046 > > Private Const SRCPAINT = &HEE0086 > > Private Const WHITENESS = &HFF0062 > > Private Sub Command1_Click() > > ' This example assumes that you have the scale mode set to > > ' pixels (vbPixels). > > ' A variable for containing the return value of the API > > ' function. Non-zero on success, zero on failure. > > Dim lngRetVal As Long > > ' Merge the image from Picture2 with the image from Picture1. > > lngRetVal = BitBlt(Picture1.hDC, 0, 0, Picture2.ScaleWidth, _ > > Picture2.ScaleHeight, Picture2.hDC, Picture2.ScaleLeft, _ > > Picture2.ScaleTop, MERGEPAINT) > > If lngRetVal = 0 Then MsgBox "Unable to copy source " _ > > & "to destination!", vbExclamation, "ATTENTION!" > > End Sub > > --- > > Sheppe Pharis, MCP * 3/Tekmetrics VB Certified > > VB5/VB6/VBA/VBS/ActiveX/API Developer
|
Sat, 25 May 2002 03:00:00 GMT |
|
 |
sa.. #6 / 18
|
 fading of two pictures (blend one picture into the other)
(I am responding to the response because my newsserver skips messages like mad :) ) Quote: >>hello, >>does anybody know how to fade one picture into another. >>or to blend between two pictures? >>is there a control or some sample code? >>ernst
Ernst, To blend two images, all you have to do is take the average of the red, green, and blue values of the corresponding pixels, and output that value to the destination image. If you want to have one image more visible than the other, you need to bias the percentage of the input values to reflect the proportion. For example, if you wanted 25% of image #1 blended with 75% of image #2, you would simply take 25% of each color value of image #1 (red, green, blue), and add it to 75% of each color value from image #2. To access the rgb values of each pixel, I know of four methods: the Point method (unbearably slow) the GetPixel API call (tolerable speed for small images) the GetBitmapBits API call (fast, but complicated) the GetDIBits API call (faster, but more complicated) Use the RtlMoveMemory API call to cast a long RGB value into an RgbTriple (or Quad) UDT, or alternatively, you can also use LSet to do the same thing. If you want to fade one picture into another in realtime, such as for a slideshow transition, I doubt any of these methods will suit your needs, but for creating animated GIF frames or AVI frames, just apply the previous method(s), but start with a low percentage for image #2 and a high percentage for image#1 (equalling 100%) and then increase and decrease the percentages of each image accordingly. Cheers, Jeremiah D. Seitz Omega Techware Solutions for small businesses and shareware ActiveX controls. http://omegatechware.hypermart.net
|
Sun, 26 May 2002 03:00:00 GMT |
|
 |
Gary Chamberlain / BS #7 / 18
|
 fading of two pictures (blend one picture into the other)
Check out ImgX at http://DesignerControls.com/ImgX It has a fade method that will allow the fadesteps to be created to fade between the two images..
Quote: > hello, > does anybody know how to fade one picture into another. > or to blend between two pictures? > is there a control or some sample code? > ernst
|
Sun, 26 May 2002 03:00:00 GMT |
|
 |
Lewis Pricha #8 / 18
|
 fading of two pictures (blend one picture into the other)
Quote:
>hello, >does anybody know how to fade one picture into another. >or to blend between two pictures? >is there a control or some sample code?
After trying out a couple of the samples posted here, I think this one looks nicer. It assumes you have created a form and placed on it an array of three pictureboxes and a timer control. I suppose it is much more convoluted than necessary, but I was doing a lot of fiddling around and can't be bothered tidying it up right now. Oh yes! All pictureboxes should use scalemode 3 (pixel), and pictureboxes 0 and 1 should have pictures loaded into them at design time. Sorry, I just used a double-click on the form to start it, rather than a command button. Option Explicit DefLng A-Z Dim Match() As Boolean Dim PicMaxX As Long, PicMaxY As Long Dim PicMaxXPlus1 As Long, PicMaxYPlus1 As Long Dim Matches As Long, MatchesRequired As Long Private Sub Form_DblClick() Timer1.Enabled = True End Sub Private Sub Form_Resize() Picture1(0).Move 0, 0, Me.ScaleWidth / 2, Me.ScaleHeight / 2 Picture1(1).Move Me.ScaleWidth / 2, 0, _ Me.ScaleWidth / 2, Me.ScaleHeight / 2 Picture1(2).Move Me.ScaleWidth / 4, Me.ScaleHeight / 2 _ , Me.ScaleWidth / 2, Me.ScaleHeight / 2 End Sub Private Sub Timer1_Timer() Static Busy As Boolean Dim x As Long, y As Long If Busy Then Exit Sub Busy = True Timer1.Enabled = False DoEvents PicMaxX = Picture1(0).ScaleWidth - 1 PicMaxY = Picture1(0).ScaleHeight - 1 PicMaxXPlus1 = PicMaxX + 1 PicMaxYPlus1 = PicMaxY + 1 MatchesRequired = PicMaxXPlus1 * PicMaxYPlus1 ReDim Match(0 To PicMaxX, 0 To PicMaxY) Picture1(2).Picture = Picture1(1).Picture Do x = Rnd * (PicMaxX) y = Rnd * (PicMaxY) If Not Match(x, y) Then Me.Picture1(2).PSet (x, y), Picture1(0).Point(x, y) Match(x, y) = True Matches = Matches + 1 DoEvents If Matches >= MatchesRequired Then Beep Exit Do End If End If Loop End Sub
|
Sat, 01 Jun 2002 03:00:00 GMT |
|
 |
Peter Quic #9 / 18
|
 fading of two pictures (blend one picture into the other)
Lewis, Nice job, to speed it up use SetPixel Picture1(2).hdc, x, y, GetPixel(Picture1(0).hdc, x, y) instead of Me.Picture1(2).PSet (x, y), Picture1(0).Point(x, y) Declare the API's as Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long Pete
|
Sat, 01 Jun 2002 03:00:00 GMT |
|
 |
Lewis Pricha #10 / 18
|
 fading of two pictures (blend one picture into the other)
Quote:
>hello, >does anybody know how to fade one picture into another. >or to blend between two pictures? >is there a control or some sample code?
After trying out a couple of the samples posted here, I think this one looks nicer. It assumes you have created a form and placed on it an array of three pictureboxes and a timer control. I suppose it is much more convoluted than necessary, but I was doin g a lot of fiddling around and can't be bothered tidying it up right now. Oh yes! All pictureboxes should use scalemode 3 (pixel), and pictureboxes 0 and 1 should have pictures loaded into them at design time. Sorry, I just used a double-click on the form to start it, rather than a command button. Option Explicit DefLng A-Z Dim Match() As Boolean Dim PicMaxX As Long, PicMaxY As Long Dim PicMaxXPlus1 As Long, PicMaxYPlus1 As Long Dim Matches As Long, MatchesRequired As Long Private Sub Form_DblClick() Timer1.Enabled = True End Sub Private Sub Form_Resize() Picture1(0).Move 0, 0, Me.ScaleWidth / 2, Me.ScaleHeight / 2 Picture1(1).Move Me.ScaleWidth / 2, 0, _ Me.ScaleWidth / 2, Me.ScaleHeight / 2 Picture1(2).Move Me.ScaleWidth / 4, Me.ScaleHeight / 2 _ , Me.ScaleWidth / 2, Me.ScaleHeight / 2 End Sub Private Sub Timer1_Timer() Static Busy As Boolean Dim x As Long, y As Long If Busy Then Exit Sub Busy = True Timer1.Enabled = False DoEvents PicMaxX = Picture1(0).ScaleWidth - 1 PicMaxY = Picture1(0).ScaleHeight - 1 PicMaxXPlus1 = PicMaxX + 1 PicMaxYPlus1 = PicMaxY + 1 MatchesRequired = PicMaxXPlus1 * PicMaxYPlus1 ReDim Match(0 To PicMaxX, 0 To PicMaxY) Picture1(2).Picture = Picture1(1).Picture Do x = Rnd * (PicMaxX) y = Rnd * (PicMaxY) If Not Match(x, y) Then Me.Picture1(2).PSet (x, y), Picture1(0).Point(x, y) Match(x, y) = True Matches = Matches + 1 DoEvents If Matches >= MatchesRequired Then Beep Exit Do End If End If Loop End Sub
|
Sat, 01 Jun 2002 03:00:00 GMT |
|
 |
Peter Qui #11 / 18
|
 fading of two pictures (blend one picture into the other)
Lewis, Nice job, to speed it up use SetPixel Picture1(2).hdc, x, y, GetPixel(Picture1(0).hdc, x, y) instead of Me.Picture1(2).PSet (x, y), Picture1(0).Point(x, y) Declare the API's as Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long Pete
|
Sat, 01 Jun 2002 03:00:00 GMT |
|
 |
Lewis Pricha #12 / 18
|
 fading of two pictures (blend one picture into the other)
On Tue, 14 Dec 1999 09:31:17 +0100, "Peter Quick" Quote:
>Lewis, >Nice job, >to speed it up use > SetPixel Picture1(2).hdc, x, y, GetPixel(Picture1(0).hdc, x, y) > ...
Sorry, I've been pretty busy. I tried your suggested modification. Managed to get it working eventually, too, once I realised that I needed to set my scalemode back to 0 - twips. Unfortunately, it is now EXTREMELY slow, since it has to do about 9.8 million comparisons and moves, compared to about 44,000 in my original version. Am I doing something wrong?
|
Mon, 01 Jul 2002 03:00:00 GMT |
|
 |
Lewis Pricha #13 / 18
|
 fading of two pictures (blend one picture into the other)
On Tue, 14 Dec 1999 09:31:17 +0100, "Peter Quick" Quote:
> SetPixel Picture1(2).hdc, x, y, GetPixel(Picture1(0).hdc, x, y)
Oh, I forgot to mention. Doing it this way sucked up a HUGE amount of RAM, due to the enormous size (9.8 million elements) of the "Match" array. Also, this size grows very rapidly as you increase the size of the form. I suppose, in theory, a picture box could be up to 800x600 (48,000) pixels, in my current resolution. But in twips, it looks like it might be something on the order of 12,000x9,000 (108,000,000) "points" to deal with. That could make for quite a large array.
|
Mon, 01 Jul 2002 03:00:00 GMT |
|
|
Page 1 of 2
|
[ 18 post ] |
|
Go to page:
[1]
[2] |
|