?
Solved

Fading in an image

Posted on 2003-03-16
5
Medium Priority
?
273 Views
Last Modified: 2010-05-01
I am looking for a way to have an image fade in.  What I need to have happen is:  when running the picture would appear blacked out, and have small squares reveal one at a time until the whole image is revealed.

Thank you
0
Comment
Question by:egroegeinrub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Accepted Solution

by:
supunr earned 800 total points
ID: 8149788
This is NOT a neat solution.  but might worth while trying this.  You have to put the image in an image control, not a picture box.  Need a image control called "Image1" and timer control called "Timer1"

Option Explicit

Dim imgIndex As Long
Dim Shape1(24) As Shape

Private Sub Form_Load()
    Dim i As Long
    Dim j As Long
   
    For i = 0 To 24
        Set Shape1(i) = Controls.Add("VB.Shape", "shape_" & i)
    Next i
    For i = 0 To 24
        Shape1(i).Width = Image1.Width / 5
        Shape1(i).Height = Image1.Height / 5
        Shape1(i).Move Int(i / 5) * Shape1(i).Width + Image1.Left, (i Mod 5) * Shape1(i).Height + Image1.Top
        Shape1(i).Visible = True
        Shape1(i).BackStyle = 0 'solid
        Shape1(i).FillStyle = 0 'solid
        Shape1(i).ZOrder
    Next i
End Sub

Private Sub ShowImage()
    Timer1.Interval = 50
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Shape1(imgIndex).Visible = False
    imgIndex = imgIndex + 1
    If (imgIndex > 24) Then
        imgIndex = 0
        Timer1.Enabled = False
    End If
End Sub


Good Luck!
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8149982
theres two methods a hard an easy way. the hard way isnt too hard though. hard way is to use GetDiBits and get the images rgb values stored into an array and then get the difference between the colors and a certain percentage to add.
so if you want the images to go through 10 steps till they are completely faded into the other, if pic1's red value starts at 0 and pic2's is 100 for that particular pixel you take 100-0 = 100 then get 10 percent
= 10 and then next time youll get 20% of the difference until they = the same
you dont have to change anything for subtracting cause the number youll get with be negative, it'll work out
ie. pic1 red = 50 pic2 red = 25
25-50 = -25
so when you add a % of that youll be taking away from pic1'a red not adding.
quick easy way is to make a picturebox and set the backcolor to black then bitblt the image onto it using (i believe SRCPAINT) then set the picture a little whiter and do the same till its white
so have variables for red green and blue and keep incrementing and set the backcolor to RGB(red,green,blue)
then use bitblt and SRCPAINT
the pic will fade from black. im not 100% sure it's SRCPAINT i dont have any of my source code right now, i had to format my drive and my programming stuff hasnt been copied from a backup hard drive yet.
0
 

Expert Comment

by:CleanupPing
ID: 8532228
Hi egroegeinrub,
This old question (QID 20553028) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8956487
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Accept supunr's comments as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8956488
nice code supunr.  Adding to my library
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question