Results 1 to 9 of 9

Thread: StretchBlt if you dare!!!

  1. #1

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Question

    A have a picturebox on my screen (Visible=True) with dimensions 2000x2000 pixels. It doesn't fit in the 1024x768 screen.
    When I StretchBlt the thing to a 400x400 picturebox, everything beyond 1024x768 looks "scrambled".
    I set the StretchBltMode to 4 (smoothing), the scrambling remains the same...
    How the hell can I retrieve the invisible part?
    At the moment, I have to redraw the picture with a different offset until 2000x2000 has been reached. But I think there's a better solution, which, unfortunately, I can't remember!

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Here's what I use

    I have used this to successfully zoom in or out of an image. For convenience I declare the following:

    Code:
    Public Enum StretchMode
      ANDSCANS = 1
      DELETESCANS = 3
      HALFTONE = 4
      ORSCANS = 2
    End Enum
    Note that you're using HALFTONE but I always have used DELETESCANS. This is the best choice when shrinking an image I believe. Halftone would be suitable for zooming in I think, except that I notice in my code I just use DELETESCANS exclusively...

    I guess I must have read it somewhere...

    My other declares are:
    [code]
    Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

    Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
    [code]

    Hope it helps.



    Paul Lewis

  3. #3
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    Red face

    just put the thing you have in your huge PicBox in another (visible =false, autoredraw = true)
    and blit from this one.

    That's all
    I hope I could help you
    Sanity is a full time job

    Puh das war harter Stoff!

  4. #4

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Thnaks for replying.
    But there is still a little problem.
    My picturebox contains gfx, after loading from a database file (which contains types, structures and x-y stuff).
    BUT: it also contains Label controls...
    A Blt of this picturebox would not contain these label controls, except if I should use the GetWindowDC() API. But this API only accepts the visible window area, doesn't it?
    Well, that's my question: how to include the label controls - on a 2000x2000 picturebox - in the StretchBlt command?

  5. #5
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    That puts a different light on the subject

    I don't think I realised you had label control you were attempting to merge with the image.

    Once again however, I have done a very similar thing in the app I referred to earlier. I didn't use controls however, I simply BitBlt'd the text (called an annotation) onto the image. At that point, my app would save the image and should a user wish to remove the annotation in the future, they were out of luck. If I had wanted to I could have stored the image and annotation seperately however my app was involving live video capture during a laproscopic procedure and it was VERY important that should an image produced from my system be emailed, there was no chance of the serial number of the image being mixed up due to some stupid database error.

    To cut a long story short, you can BitBlt the text you want onto the image, then if AutoUpdate is set to true, the merged text is part of the image. If you need to, store the text seperately so that if the user changes the text, then you can recreate the image again.

    Oversimplifiying I know, but from the sound of your posts you know what you're doing (more so than me no doubt).

    I would offer my actual classes however I am in the process of negotiating a sales/marketing deal and I would hate for any part of the code to be inadvertantly put into the public domain. If you need more details though, I would be happy to cut and paste the few lines at the guts of the code.

    Regards
    Paul Lewis

  6. #6
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    Wink

    Just use textout to blt the text onto the pic!

    It may seem to simple but I think it's a solution!
    Sanity is a full time job

    Puh das war harter Stoff!

  7. #7

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Thanks, /\/\isanThr0p and Paul.
    That's what I also had in mind:
    To StretchBlt the picture's created image, and after that, just do the several TextOut into the device's DC.
    Thanks for the support, guys.

    PS. I recently created an algorithm to move a transparent picture VERY fast and smoothly. Functions like TransparentBlt and derivates also works, but it's very stupid to do scrolling with it.
    So I worked with memory DC's and BitBlt.
    The app I made, scrolls a 256colour transparent GIF in a circle and while moving the mousecursor, the circle's center also changes! Everything happens very fast and smoothly.
    If you're interested I could mail you the source. It's all written in clear, simple VB...

    bye

  8. #8
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Go ahead...

    I'm always interested in learning something new.

    Cheers
    Paul Lewis

  9. #9
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    Cool

    As always I have the same opinion as Paul, so go for it.

    if you like it more to email:
    [email protected]
    Sanity is a full time job

    Puh das war harter Stoff!

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