Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

bitmap manipulation

Posted on 1998-11-18
4
Medium Priority
?
240 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
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

886 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