CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2005
    Location
    Bremen, Germany
    Posts
    33

    Angry Problem in Stretching the Drawn image

    Dear Friends,
    I am doing a project - in which i have an array of points world coordinates. Using that I Draw the image using SetPixel(). After that using rectangle tool in the menu, User select on the image to get the coordinates, on which the measurement should take place

    The problem is now I wanna increase the image size ,like increasing the individual pixel size or increasing the scaling factor in a Graph.

    For your kind view, I attach the project here.(visual c++ 6.0)

    Please help me in this regard.

    cheers
    kingsly
    Attached Files Attached Files
    kings4u

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Problem in Stretching the Drawn image

    You can use StretchBlt or StretchDIBits to stretch an image and use SetStretchBltMode to change the quality of the scaling.

    Note: using SetPixel is generally not a good idea because it's pretty slow. It's much beter to work directly into the memory buffer for the image. You can get the pixel array from an existing bitmap with GetDIBits or you can create your bitmap withCreateDIBSection which returns the HBITMAP and a pointer to the pixel buffer which you can manipulate.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Jul 2005
    Location
    Bremen, Germany
    Posts
    33

    Re: Problem in Stretching the Drawn image

    Thank you Marc G for your info.

    As I am newbie, I find little bit difficult in implementing this. But I try maximum and get back to you.

    Once again thankyou for your help

    cheers
    kingsly
    kings4u

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: Problem in Stretching the Drawn image

    you can look at this thread:
    Bitmap in CStatic.
    it demonstrates how to use ::StretchDIBits(..).

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  5. #5
    Join Date
    Jul 2005
    Location
    Bremen, Germany
    Posts
    33

    Re: Problem in Stretching the Drawn image

    Thankyou golanshahar for your info..

    I am workin on it. I have some basic doubts

    1. If we zoom the object, will the coordinates changes accordingly to the
    window or what?- Hope my question is clear (so that I can get the
    same coordinates as in original size when its in enlarged mode)

    2. I tried to use CreateDIBSection()... which has lot and lot of parameters
    which I dont know how to pass... For Setpixel() I just pass the window
    coordinates and the color.

    Is that, for zooming a painted operation should be a bitmap? because my application is small paint operation.

    Sorry! if I'm asking too many questions...

    Waiting for your reply guys--

    cheers
    kings4u

  6. #6
    Join Date
    Jul 2005
    Location
    Bremen, Germany
    Posts
    33

    Re: Problem in Stretching the Drawn image

    hallo,
    sorry for asking again and again ..

    I dont have a file which contains bitmap data.

    the text file i have , just give the coordinate of the object from the world coordinates..

    so that, i used setpixel to display the image..

    can any one please help me in making the object full screen..

    waiting for your reply.
    kings4u

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Problem in Stretching the Drawn image

    Start by learning how to use CreateDIBSection.
    There are some samples in the MSDN that uses CreateDIBSection. Perhaps you can look at them to try to understand how they work:
    http://msdn.microsoft.com/library/de...e_mfc_FIRE.asp
    or
    http://support.microsoft.com/default...NoWebContent=1

    When you use CreateDIBSection you'll get a pixel buffer. You can then simply write pixel data into that buffer. For example: if your pixel buffer is called pBuff, you can do the following:
    Code:
    pBuff[0] = 255;
    pBuff[1] = 0;
    pBuff[2] = 0;
    Which will set the first pixel to blue. Remember that bitmap buffers in windows are BGR(A) and not RGB(A).

    Once you've done that, you can use StretchDIBits to blit and stretch your image.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

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

Featured