Solved

BitBlt in VB

Posted on 2002-04-30
4
317 Views
Last Modified: 2010-07-27
I have the following bit of code in my application:
    Set picSource.Picture = LoadPicture(sFile)
    Const PIXEL = 3
    picSource.ScaleMode = PIXEL
    picDest.ScaleMode = PIXEL
    hDestDC = picDest.hDC
    x = 0
    y = 0
    ' Assign information of the source bitmap.
    hSrcDC = picSource.hDC
    lReturn = BitBlt(hDestDC, _
                     0, _
                     0, _
                     iWidth, _
                     iHeight, _
                     hSrcDC, _
                     iLeft, _
                     iTop, _
                     &HCC0020)


The picture loads into picSource okay, and the DCs appear to be set up correctly. But after the BitBlt, picDest.picture is always empty (ie., 0). The idea of the exercise is to copy a section (bounded by iLeft, iTop, iWidth, iHeight) of the picture in picSource to picDest. But, obviously, it's not working. Why not?
0
Comment
Question by:toff_in_sydney
[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
  • 3
4 Comments
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6980028
Look at this Excellent Code

http://www.freevbcode.com/ShowCode.Asp?ID=3677

Narayanan
0
 
LVL 15

Expert Comment

by:ameba
ID: 6980044
Drawing on the picturebox (or form) doesn't change its Picture property.
What will be different is picDest.Image, not picDest.Picture.
Use  "picDest.Picture = picDest.Image", or, after drawing, use "picDest.AutoRedraw = False", e.g.:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    AutoRedraw = True
   
    ' draw something
    Me.Line -(X, Y)
   
    AutoRedraw = False   ' make permanent picture
End Sub
0
 
LVL 15

Accepted Solution

by:
ameba earned 300 total points
ID: 6980058
picDest.Image will have the size of the control, so you'll have to set dimensions of picDest.

Instead of BitBlt, you can directly produce the picture using PaintPicture method.
0
 
LVL 15

Expert Comment

by:ameba
ID: 7137404
Explanation to EE (No, I am not asking you to change the grade)

I correctly answered the question, not with one solution, but with all practical solutions, and all with the required code.
solution 1:
Use  "picDest.Picture = picDest.Image"

solution 2:
is a complete drawing program which shows how to make permanent picture using AutoRedraw

I have also given the alternative to BitBlt:

>Instead of BitBlt, you can directly produce the picture using PaintPicture method.

It seems user have jumped to the alternative, without reading or understanding the first part of my post, and instead of posting feedback in this question, he posts a new question about PaintPicture.
http://www.experts-exchange.com/visualbasic/Q_20295350.html
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

738 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