dcsimg
Results 1 to 26 of 26

Thread: StretchBlt vs Enlarging Image Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    StretchBlt vs Enlarging Image Control

    I have a Picturebox with an image in it. I also have an Image Control with the same image in it. Both the Picturebox and Image Control are 25 x 25.

    I use StretchBlt to enlarge the picture in Picture1 to Picture2 to 400 x 400. The enlarged picture looks terrible because of the jagged edges. But if I enlarge the same picture in the Image Control by stretching it's width and height to 400 x 400 the enlarged picture looks extremely smooth, no jagged edges.

    So, my question is what does the Image Control do differently when enlarging a picture than the StretchBlt does.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    Even without SetStretchBltMode, I haven't noticed dramatic rendering quality between StretchBlt (better: yes, dramatic: no) and that of an image control with Stretch property set to true. From the description you provided, almost sounds like the image control is using bicubic rendering (extremely smooth edges) where StretchBlt uses nearest-neighbor (jagged edges).

    In the screenshot below (resized by the forum), the images look identical. Left side is the image control, the right side is a picturebox rendered with StretchBlt w/o SetStretchBltMode.

    Image source is 61x61 and stretched to 488x488

    By chance, are you using that class of mine from your "Orbiting Balls" thread?

    Name:  SShot2.jpg
Views: 96
Size:  20.2 KB
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Fanatic Member
    Join Date
    Dec 2014
    Posts
    757

    Re: StretchBlt vs Enlarging Image Control

    windows 10 has gdi scaling functions right? maybe its not the image control but windows 10 that do the scaling while the other is the stretchblt

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    Don't know about image control using bicubic rendering (extremely smooth edges). All I know is I put the image (bmp) in a picturebox and the same image in an Image Control. I stretch both. For the bitmap picture in the picturebox I use StretchBlt and for the picture in the Image Control I just increase the size of the control. When the pictures get bigger the picturebox is jagged but the Image Control is smooth (just as smooth as the original picture).

    No, I am not using your class. This is a game I am working on and all the code is what I write.

    I will play around with what dile suggested by using SetStretchBltMode(). and see what happens.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    So, when you use StretchBlt which image handle are you putting into the source hDC? Is it the image control's picture handle or is it the picturebox's .Image property's handle or the .Picture property's handle. I'm wondering if you may be resizing a rendered image vs rendering from a static image. In other words, if you resize something, then resize that result again, and that new result again and so on -- the quality will be horrific. But if you use the same unchanged image handle every time, you should get better results.

    If you are willing the share the bitmap, I'd like to try to replicate the problem.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    Quote Originally Posted by LaVolpe View Post
    So, when you use StretchBlt which image handle are you putting into the source hDC? Is it the image control's picture handle or is it the picturebox's .Image property's handle or the .Picture property's handle.
    Code:
     dW = dW + 5
     dH =  dH + 5
    
     StretchBlt(Picture2.hDC, 0, 0, dW, dH, _
                Picture1.hDC, 0, 0, Picture1.Width, Picture1.Height, _
                vbSrcCopy)
    Quote Originally Posted by LaVolpe View Post
    I'm wondering if you may be resizing a rendered image vs rendering from a static image. In other words, if you resize something, then resize that result again, and that new result again and so on -- the quality will be horrific. But if you use the same unchanged image handle every time, you should get better results.
    Am I not resizing the original.
    Last edited by Code Dummy; Feb 12th, 2019 at 06:04 PM.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    Am I not resizing the original.
    Should be if Picture1 is 25x25 and AutoRedraw=True and the original 25x25 image was drawn on to it. But without more details how Picture1 was setup, can't answer for sure. Also, I'm guessing you are clearing/erasing Picture2 before rendering?

    There is a better way to do this if you only want to render a single picture vs an entire hDC. You use the image's Render method.

    For this example, the picture to be rendered is loaded into a Image/PictureBox control or a stdPicture object, i.e.,
    Dim thePic As StdPicture: Set thePic = LoadPicture(...)

    Code:
     Dim X As Single, Y As Single ' left/top respectively
    Dim cX As Single, cY As Single  ' width/height respectively
    
    ' swap Image1.Picture below with a stdPicture object if you chose that route
    
    cX = Picture1.Width ' assuming picture1 parent's scalemode is pixels
    cY = Picture1.Height ' X,Y,cX,cY must be in pixels only, not twips or anything else
    
    With Image1.Picture
        .Render (Picture2.hDC), X, Y, cX, cY, 0!, .Height, .Width, -.Height, ByVal 0&
    End With
    Last edited by LaVolpe; Feb 12th, 2019 at 06:19 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    I tried your approach but it doesn't improve on the flicker. As far as smooth edges are concerned I did a little experimenting and I found that if I start out with a small image loaded into the Image Control then using a timer and increase the width and height of the control on each timer event the edges start to appear jagged as the image get bigger and bigger. However, if I load an image that is as big as I want to get into the Image Control then start out with the Image Control as a small square then increase it on each timer event the image doesn't get jagged edges as it gets bigger and bigger

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    What size is the actual image, as shown in the file properties? Flicker is a different issue altogether
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    Quote Originally Posted by LaVolpe View Post
    What size is the actual image, as shown in the file properties? Flicker is a different issue altogether
    I have the same picture in two .gif files. One file is small 25 x 25 and the other is large 500 x 500.

    If I use the small file and gradually increase it up to the max size I want in my project about 700 x 700 it gets highly jagged edge when it starts to get around 100 x 100 and bigger the jagged edges become more and more obvious. Now on the other hand if I start out with the big gif image but make the Image Control small (25 x 25) and enlarge it's width and height the picture stays smooth even up to the 700 x 700 max size in my project. So, I am convinced to use a large image as opposed to a small image.

    Now, I need to find a way to avoid the flicker especially as the picture gets bigger and bigger. I'm sure there are other ways to do what I am doing with Image Controls but it seems that using Image Controls is the easiest because it is easy to move them around while increasing their sizes. No need to erase and redraw. Moving them around does not cause a problem; just resizing them causes the flickering.

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    That was what I was thinking. To say that the image control was nice & smooth was misleading. Even at 400x400, you are not increasing the size of the base image (500x500). Reducing size scales/draws better than increasing. If you were to put that 25x25 picture in the image control and stretch it to 400x400, you should get the jaggies.

    Recommendation. Use larger image and scale down instead of using smaller image and scaling up.

    Edited: Just for clarification. If you have a 500x500 picture inside an image control stretched to 25x25, the image isn't 25x25. It is still 500x500 scaled down to 25x25. So when you then stretch the image control to 400x400, you are still reducing the 500x500 to 400x400
    Last edited by LaVolpe; Feb 12th, 2019 at 10:09 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,797

    Re: StretchBlt vs Enlarging Image Control

    Quote Originally Posted by Code Dummy View Post
    I have a Picturebox with an image in it. I also have an Image Control with the same image in it. Both the Picturebox and Image Control are 25 x 25.

    I use StretchBlt to enlarge the picture in Picture1 to Picture2 to 400 x 400. The enlarged picture looks terrible because of the jagged edges. But if I enlarge the same picture in the Image Control by stretching it's width and height to 400 x 400 the enlarged picture looks extremely smooth, no jagged edges.

    So, my question is what does the Image Control do differently when enlarging a picture than the StretchBlt does.
    So, you didn't really have the same image, you had a larger image in the Image Control.
    Despite the name, i.e. StretchBlit, you can resize in both directions, i.e. the stretch can actually be a shrink if you start with a larger image and blit to a smaller area.

    An image control will always tend to flicker since it is a lightweight control, so isn't its own window. It has to draw on its container, which means it is being drawn on the screen while you watch. And since it has to redraw the background of the container it is in, you often catch it in the process of being drawn as it first erases the previous version of itself, restoring the background, then redrawing itself on top.

    A picturebox is its own window, so it can be doubled buffer, so you don't see the drawing process. And even it if isn't double buffered, it doesn't have to draw draw the background of the container within its borders, first, before drawing itself.

    I don't know what your game needs are, but for most games, I would double-buffer the whole drawing area, and draw the whole thing in the backbuffer and then refresh the whole scene at once.

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    Quote Originally Posted by Code Dummy View Post
    Now, I need to find a way to avoid the flicker especially as the picture gets bigger and bigger. I'm sure there are other ways to do what I am doing with Image Controls but it seems that using Image Controls is the easiest because it is easy to move them around while increasing their sizes. No need to erase and redraw. Moving them around does not cause a problem; just resizing them causes the flickering.
    As passel mentioned... Common way is to use an offsreen buffer, draw your updates to that and then either copy the entire buffer to your display, or just affected portions. On slower PCs (remember those?), flicker is even worse.

    However, don't know if this hack is still legitimate and works as it did in older systems. The idea was to have Windows do the buffering for us, at the form level. This was achieved by adding, to the form, the extended window style bit: WS_EX_LAYERED. Then calling SetLayeredWindowAttributes setting form opacity to 99%. Once SetLayeredWindowAttributes is called, supposedly Windows draws the form in a buffer then updates the screen. So most/all of that flickering occurs off-screen. Anyway that was a hack for XP/Win2K times. But he standard workaround is to do the buffering yourself.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    Well, I have decided not to pursue this approach anymore as I can now see that it is not going to get me where I want without the curse of flickering so I have decided to take advantage of your pretty Form project. Maybe there I will learn a few things about buffering.

  15. #15
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    Note that that project uses backbuffers. If I were to actually load the PNGs into the image controls, I would get flickering too as they moved around the form. In any case even with images having transparency, flicker can be even worse if any images happen to overlap because that causes multiple images to repaint their backgrounds.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  16. #16
    Fanatic Member
    Join Date
    Dec 2014
    Posts
    757

    Re: StretchBlt vs Enlarging Image Control

    remember that u can use direct2d, u can use linear interpolation for the resize mode, u dont need to think about buffering and direct2d can control dpi.

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    I'm playing around with your pretty Form project. One thing I am having trouble with is resizing the sun. From looking at the code in PlotPlanets where you render the sun...
    Code:
       '
       '
       '
    With mSun
      Cx = .radSelf + .radSelf
    
      .Picture.Render (mDC), CtrX - .radSelf, CtrY - .radSelf, Cx, Cx, _
                       0, .Picture.Height, .Picture.Width, -.Picture.Height, ByVal 0
    End With  
       '
       '
    I'm assuming that Cx is the size of the rectangle (.radSelf + .radSelf or radius of itself x 2) that holds the picture of the sun. So, it appears to me that to increase the size of the sun all I have to do is add a value to Cx to make the sun bigger and then reduce the X and Y by the same value.

    So I do this: (variables already defined)

    NewCx = NewCx + 2 increase the diameter by 2

    Cx = .radSelf + .radSelf + NewCx

    NewCtrX = NewCtrX + 2
    NewCtrY = NewCtrY + 2

    .CtrX - .radSelf - NewCtrX
    .CtrY - .radSelf - NewCtrY

    .Picture.Render (mDC), CtrX, CtrY, Cx, Cx, _
    0, .Picture.Height, .Picture.Width, -.Picture.Height, ByVal 0

    OK, the sun gets bigger as expected but the x and y doesn't work. As the Sun gets bigger it moves diagonally across the screen. I would have expected the location of the sun would stay centered. What am I doing wrong.

  18. #18
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    To resize the sun, resize the top image control in the form.

    To try to answer your question
    .radSelf is 1/2 the width or height (square). So if you are going to try to increase Cx, make .radSelf = Cx/2 (radius)

    CtrX and CtrY are the center points to render the center of the sun to. So you want the center of the sun (Cx/2 which is also .radSelf) centered on Cx. The left edge of the sun will be CtrX - .radSelf
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    OK, about resizing the image control I made this little routine using your code

    Code:
    Private Sub PlotPlanets()
      '
      '
      '
     With mSun
       ResizeSun
    
       Cx = .radSelf + .radSelf
     
      .Picture.Render (mDC), CtrX - .radSelf, CtrY - .radSelf, Cx, Cx, _
                            0, .Picture.Height, .Picture.Width, -.Picture.Height, ByVal 0
     End With
       '
       '
    End Sub
    
    Private Sub ResizeSun()
     Dim tPic As StdPicture  
     Dim tScale As Double
    
     spSun.Width = spSun.Width + 1 
     spSun.Height = spSun.Height + 1 
    
     tScale = 0.95            
    
     With mSun
       .radSelf = (spSun.Width / 2) * tScale
       Set tPic = cPics.LoadPictureEx(App.Path & "\Planets\Sun.png")
       Set .Picture = cPics.CopyStdPicture(tPic, spSun.Width * tScale, spSun.Height * tScale)
     End With
     
     Set tPic = Nothing
    End Sub
    It works fine. The only drawback is I have to reload the Sun.png each time

  20. #20
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    No. You can load it one time, full image size. You'll notice in the routine where they are loaded, I call a method to resize the images to the size that would be used in the program. This was to speed up rendering since we wouldn't need to be scaling the image every time it is rendered.

    Simply modify the lines in that pvResetScreen routine as follows or in Form_Load if using an older version of the project:
    Code:
    ' From
    ...
            Set tPic = cPics.LoadPictureEx(App.Path & "\Planets\Sun.png")
            Set .Picture = cPics.CopyStdPicture(tPic, spSun.Width * tScale, spSun.Height * tScale)
    ...
    
    ' To
            Set .Picture = cPics.LoadPictureEx(App.Path & "\Planets\Sun.png")
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  21. #21
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,621

    Re: StretchBlt vs Enlarging Image Control

    Not to horn in because this is not my area of expertise, but I'm not seeing terrible flicker even if I fullscreen this demo:

    Name:  sshot.png
Views: 31
Size:  5.2 KB

    But maybe this is too simplistic to encounter it?


    Sorry, still some glitches in the animation logic related to Form resizing even after fiddling with it. But that wasn't really the point anyway. Feel free to fix it if you care.
    Attached Files Attached Files
    Last edited by dilettante; Yesterday at 12:09 AM. Reason: Fixed Form resize, added a cat

  22. #22
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    dilettante, he was using image controls. At least that is the way I interpreted him.

    I'd imagine if you add a GIF to an Image control and move it around at intervals less than full width/height of the control (i.e., small intervals), at a speedy rate, you might see flickering.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  23. #23
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,621

    Re: StretchBlt vs Enlarging Image Control

    Sorry, I thought you had talked him out of that.

  24. #24
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    Quote Originally Posted by dilettante View Post
    Sorry, I thought you had talked him out of that.
    Think he talked himself out of it. What he's talking about now is an option I presented in his "Orbting Balls" thread last week. That option uses backbuffers like many animation routines. Now, I think he's trying to figure out how to adjust the logic to fit his needs.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Apr 2017
    Posts
    231

    Re: StretchBlt vs Enlarging Image Control

    OK, I tried your suggestion about loading the image only once. Works great. Something really bizarre is happening however. I have two buttons on the Form; one is for enlarging the sun ball and the other is for reducing it. When I run the project everything is normal. The sun is on the stary background which covers the Picturebox completely. By default the sun gets bigger and bigger by a factor of 1. If I allow the sun to get really big, like as big as the Form and bigger then I click the button which starts to reduce the image. As the image gets smaller there's a side affect which looks like sun rays coming out from around the circumference. Also the stary background is reduced to a square in the center of the picturebox. I have included picture so you can see the affect. Any ideas what causes this.

    Here is the code I am using

    Code:
      With mSun
        Static SunWidth As Integer
        
        tScale = 0.95            ' want planet orbit to use 75% of screen height if full scale
    
        If MakeLarger Then
          SunWidth = SunWidth + VelFactor
        Else
          SunWidth = SunWidth - VelFactor
        End If
    
        .radSelf = (SunWidth / 2) * tScale
    
        Cx = .radSelf + .radSelf
        
        .Picture.Render (mDC), CtrX - .radSelf, CtrY - .radSelf, Cx, Cx, _
                        0, .Picture.Height, .Picture.Width, -.Picture.Height, ByVal 0
      End With
    Note: This only occurs if the sun is enlarged beyond the boundaries of the Picturebox and only on the top boundary.
    Attached Images Attached Images  

  26. #26
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,856

    Re: StretchBlt vs Enlarging Image Control

    Possibly something is off with the scale you are using to transfer mDC to your form? I'd look there first. It's going to be a bit tough to offer advice because it sounds like you have modified my original code (that's fine), but I don't know what it looks like now
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width