Solved

bitmap manipulation

Posted on 1998-11-18
4
232 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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
basic hardware to learn oop advanced design patterns 3 122
gdb doesn't stop on breakpoint 2 140
designing in object programming 12 131
Android development question 2 109
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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