Solved

RasterOps

Posted on 2002-06-06
19
385 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
[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
  • 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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 

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
 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this tutorial viewers will learn how to create blended and gradiated shapes in Illustrator using the blend tool Draw two shapes, one of them in a different color: Select both and create a blend by going to Object > Blend > Make: Blends can also b…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

630 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