Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

bitmap manipulation

Posted on 1998-11-18
4
Medium Priority
?
237 Views
Last Modified: 2010-04-01
i wanna know how can i map a grey level bitmap image from a size of nxm
(n and m are the width and height of the bitmap) to a size of NxM ( a different width and height) without any change in its resolution.

can anyone point me to the right source code ???
0
Comment
Question by:syepeng
[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
  • 2
  • 2
4 Comments
 

Author Comment

by:syepeng
ID: 1178201
Edited text of question
0
 
LVL 10

Accepted Solution

by:
viktornet earned 800 total points
ID: 1178202
you can use the StrecthBlt() command..

Here is a snippet code...
===================
hdcScaled = CreateCompatibleDC(hdcScreen);  
 
    hbmScaled = CreateCompatibleBitmap(hdcScreen,
                    GetDeviceCaps(hdcScreen, HORZRES) * 2,
                    GetDeviceCaps(hdcScreen, VERTRES) * 2);
 
    if (hbmScaled == 0)
        errhandler("hbmScaled", hwnd);
 
    /* Select the bitmaps into the compatible DC. */
 
    if (!SelectObject(hdcScaled, hbmScaled))
        errhandler("Scaled Bitmap Selection", hwnd);
 
case WM_COMMAND:     /* message: command from application menu */

    switch(wParam) {
 
        case IDM_SCALEX1:
            if (fBlt){
                 fScaled = FALSE;
                 hdcWin = GetDC(hwnd);
                 BitBlt(hdcWin,
                    0,0,
                    bmp.bmWidth, bmp.bmHeight,
                    hdcCompatible,
                    0,0,
                    SRCCOPY);
                 ReleaseDC(hwnd, hdcWin);
            }
            break;
 
        case IDM_SCALEX2:
            if (fBlt){

                 fScaled = TRUE;
                 StretchBlt(hdcScaled,
                     0, 0,
                     bmp.bmWidth * 2, bmp.bmHeight * 2,
                     hdcCompatible,
                     0, 0,
                     bmp.bmWidth, bmp.bmHeight,
                     SRCCOPY);
 
                 hdcWin = GetDC(hwnd);
                 BitBlt(hdcWin,
                    0,0,
                    bmp.bmWidth, bmp.bmHeight,
                    hdcScaled,

                    0,0,
                    SRCCOPY);
                 ReleaseDC(hwnd, hdcWin);
            }
            break;
=============
some parameters stuff....
------------------------
The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. Windows stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.

BOOL StretchBlt(

    HDC hdcDest,      // handle of destination device context
    int nXOriginDest,      // x-coordinate of upper-left corner of dest. rect.
    int nYOriginDest,      // y-coordinate of upper-left corner of dest. rect.
    int nWidthDest,      // width of destination rectangle
    int nHeightDest,      // height of destination rectangle
    HDC hdcSrc,      // handle of source device context
    int nXOriginSrc,      // x-coordinate of upper-left corner of source rectangle
    int nYOriginSrc,      // y-coordinate of upper-left corner of source rectangle
    int nWidthSrc,      // width of source rectangle
    int nHeightSrc,      // height of source rectangle
    DWORD dwRop       // raster operation code
   );      
 

Parameters

hdcDest

Identifies the destination device context.

nXOriginDest

Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.

nYOriginDest

Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.

nWidthDest

Specifies the width, in logical units, of the destination rectangle.

nHeightDest

Specifies the height, in logical units, of the destination rectangle.

hdcSrc

Identifies the source device context.

nXOriginSrc

Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle.

nYOriginSrc

Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle.

nWidthSrc

Specifies the width, in logical units, of the source rectangle.

nHeightSrc

Specifies the height, in logical units, of the source rectangle.

dwRop

Specifies the raster operation to be performed. Raster operation codes define how Windows combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap.
------------------------
Hope this helps you get your things done :)

Cheers,
Viktor
0
 

Author Comment

by:syepeng
ID: 1178203
Adjusted points to 200
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1178204
10x :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

688 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