Solved

RasterOps

Posted on 2002-06-06
19
375 Views
Last Modified: 2012-05-04
There are quite a few rasterop constants in VB6, but I don't know which one to use. I run into a problem that when I 'paintpicture' with an image control and that when this control passes thru other controls, it starts to flicker and very seriously. I tried the vbMergePaint, vbMergeCopy and vbpatinvert options, but neither overcomes this problem, any advice?
Regards
luckie
0
Comment
Question by:luckie
  • 13
  • 6
19 Comments
 
LVL 3

Expert Comment

by:TheRedGuy
ID: 7059307
More info, please!

What do you mean by 'passes through other controls'? Are you allowing users to drag an image control around the screen or something?

Note, also, that whilst I may be able to help, I think this Q belongs in the VB topic area...
0
 

Author Comment

by:luckie
ID: 7060790
for example, I create an image control,  the control moves from the left side to the right side. And there is another image control in the middle of the screen, when the first control overlaps with the second control, it starts to flicker... Thanks
Jacky
0
 
LVL 3

Expert Comment

by:TheRedGuy
ID: 7063646
Have you tried BitBlt instead of the PaintPicture method? Also, how important is this type of behaviour? Are you writing a game, for instance? If you post some code I'll play around with it for you with some API calls. Depends what youu are trying to achieve, though....

btw, did you post to VB topic area, too?
0
 

Author Comment

by:luckie
ID: 7063679
Well, not many points left... :)
0
 

Author Comment

by:luckie
ID: 7063865
My background is a bitmap (bmp) and my image control is a transparent gif (gif), What rasterops do I use? I want the image's back to be seen thru with the background...
Thanks
Jack
0
 

Author Comment

by:luckie
ID: 7063866
some code:

Dim x123 As Long
Dim y123 As Long


Private Sub Form_Load()
    WindowState = 2
    x123 = 11640
    y123 = 5880
    Image1.Picture = LoadPicture("C:\images\vna7.gif")
    Image1.Stretch = True
   
    Timer1.Enabled = True
    Timer1.Interval = 10
   
End Sub

Private Sub Timer1_Timer()
   x123 = x123 + 10
   y123 = y123 + 10
   PaintPicture Image1, x123, y123, 1620, 1455, 10, 10, 1620, 1455, vbSrcPaint
End Sub
0
 
LVL 3

Expert Comment

by:TheRedGuy
ID: 7064549
OK, let's make sure I understand the problem...

I ran your code and you are not moving an Image control anywhere. You are a painting a picture of the Image control directly onto the form at points X and Y. The image control remains stationary but flickers whenever you paint a picture of it onto the form. That is what you want to fix, correct?
0
 

Author Comment

by:luckie
ID: 7065997
But according to the code snippet, it should be moving at the positions of x123,y123,and yes, i want to fix the flickering happened when the image object is moving across the screen (and when two objects overlap each other)
Regards
Jacky
0
 

Author Comment

by:luckie
ID: 7066002
the control seems to be invisible at the designated positions...
Thanks
JAck
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:luckie
ID: 7066006
When I use vbSrcCopy, there is a patch of whiteness at the designated positions. However, the image can't be seen with other ops.
Thanks
Jack
0
 

Author Comment

by:luckie
ID: 7066023
It seems only working for a bmp, not a transparent gif!
Any ideas?
Rgds
Jack
0
 

Author Comment

by:luckie
ID: 7066039
I find out that the rasterops only work for bmp images, it should be left out when loading a transparent gif. But on the other hand, the transparent gif is not displayed as 'transparent'... pls help
Regards
Jack
0
 

Author Comment

by:luckie
ID: 7066058
Am I forced to use ActiveX controls?
0
 
LVL 3

Expert Comment

by:TheRedGuy
ID: 7066577
Jack,

you are NOT moving the image control at all in your code snippet! You are merely painting a picture of it ON THE FORM whilst leaving the Image control in its original location.

If you were moving the image control, then your code snippet would look more like this....

Dim x123 As Long
Dim y123 As Long


Private Sub Form_Load()
   WindowState = 2
   x123 = 11640
   y123 = 5880
   Image1.Picture = LoadPicture("C:\images\vna7.gif")
   Image1.Stretch = True
   
   Timer1.Enabled = True
   Timer1.Interval = 10
   
End Sub

Private Sub Timer1_Timer()
  x123 = x123 + 10
  y123 = y123 + 10
  With Image 1
    .Move x123, y123
  End With
End Sub


Try it and you'll see what I mean....
0
 

Author Comment

by:luckie
ID: 7066586
Thanks. I need time...getting there :)
0
 

Author Comment

by:luckie
ID: 7066588
I come back, but the image still flickering (refreshing)? Any help further?
0
 
LVL 3

Expert Comment

by:TheRedGuy
ID: 7066649
OK, I'll check that when I get home (at work currently and don't have VB)

We now agree, though, that the image control is moving now whereas it was not before, correct? However, you still have a problem with flickering which I think I can fix.
0
 
LVL 3

Accepted Solution

by:
TheRedGuy earned 50 total points
ID: 7066682
Right, add a new module to your project and paste this in:

Declare Function LockWindowUpdate Lib "user32" (ByVal hWnd As Long) As Long

Paste this into the code for your form:

Private Sub LockWindow(hWnd As Long)
    LockWindowUpdate hWnd
End Sub

Private Sub UnlockWindow()
    LockWindowUpdate 0
End Sub

Modify your snippet, replacing....

 With Image1
   .Move x123, y123
 End With
 
with this....

 LockWindow (Form1.hWnd)
 
 With Image1
   .Move x123, y123
 End With
 
 UnlockWindow


Is it OK, now? Are you running on NT or Win 95/98/2000/XP....???
0
 

Author Comment

by:luckie
ID: 7069409
Ok now, thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now