Results 1 to 9 of 9

Thread: Create "layers" like Photoshop/Paint shop pro **resolved**

  1. #1

    Thread Starter
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244

    Create "layers" like Photoshop/Paint shop pro **resolved**

    OK. I got a webcam program that I'm writing. I got everything I need including the camera capture, and the upload portion. I just want to do one thing.

    I want to add a watermark based on an image and a position that the user specifies. I have the underlying image on a picturebox and I want to put the watermark image overtop of it like another layer, then add it to the picture property.

    Anybody have any good methods of doing this?
    Last edited by WALDO; Feb 3rd, 2003 at 09:44 AM.

  2. #2
    Lively Member
    Join Date
    Mar 2002
    Posts
    110
    look up the BitBlt function in the search box. look up the raster op codes also for it, i forget which ones will give you that transparent watermark effect

  3. #3

    Thread Starter
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244

    Been trying BitBlt, no success

    VB Code:
    1. hdcWatermark = LoadImage(0, strPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
    2.  
    3.     lResult = BitBlt(frmCapture.Picture1.hdc, 0, 0, _
    4.         96 * 15, _
    5.         11 * 15, _
    6.         hdcWatermark, 0, 0, vbSrcCopy)

    No effect

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    * 15 is for..? BitBlt uses pixels, so you needn't worry about Twips. And, SrcCopy will give you a big ol' rectangle around the image...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    LoadImage doesnt reaturn an HDC.

    Z.

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Create a DC with CreateCompatibleDC, and use SelectObject to select the bitmap you get from LoadImage into it.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7

    Thread Starter
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244

    Yeah, that worked.

    Originally posted by Sastraxi
    Create a DC with CreateCompatibleDC, and use SelectObject to select the bitmap you get from LoadImage into it.
    VB Code:
    1. lResult = LoadImage(0, strPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
    2.     hdcWatermark = CreateCompatibleDC(0)
    3.     Call SelectObject(hdcWatermark, lResult)
    4.  
    5. lResult = BitBlt(frmCapture.Picture1.hdc, 0, 0, _
    6.         96 * 15, _
    7.         11 * 15, _
    8.         hdcWatermark, 0, 0, vbSrcCopy)

  8. #8
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    don't forget to delete the object or you'll crash after about 15-20 iterations depending on your memory. This code might help you delete it properly:

    Dim hMemDC As Long
    Dim hOldBMP As Long

    ' Create memory DC
    hMemDC = CreateCompatibleDC(Me.hdc)

    ' Select bitmap into it, storing the previous value
    ' (SelectObject returns the previous bitmap which
    ' was selected into the DC)
    hOldBMP = SelectObject(hMemDC, CreateCompatibleBitmap(Me.hdc, Width, Height))

    '
    ' Now you can draw...
    '

    ' First, select the old bitmap back into the DC and delete our bitmap
    DeleteObject(SelectObject(hMemDC, hOldBMP))

    ' Now delete the DC
    DeleteDC(hMemDC)

  9. #9

    Thread Starter
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244
    good to know

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width