Talk About Network

Google





Graphics > Graphics APIs > BMP image scali...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 78 of 99
Post > Topic >>

BMP image scaling and Printer resolution

by jalpa11@[EMAIL PROTECTED] Jan 2, 2007 at 08:18 PM

Hi all,

I have one EMF image which I want to convert to BMP. I want to scale
the BMP and want to display it in my view****t area. If scaled BMP
doesn't fit inside the view****t area then I want to change the scale
such that image can fit inside it.


If device is screen then my image gets scaled properly and fits inside
the view****t area. But if my device is printer then my image gets
scaled properly but it doesn't fit inside the view****t area. This is so

as printer has very high resolution and thus the number of pixels of
the scaled image are very high >1000 pixels.


I pass View****twidhtInMM, View****theightInMM, Scale,
DeviceHorzPixelsPerMM, DeviceVertPixelsPerMM to my function which
generates scaled BMP from EMF.
My code is as follow:


{
                HENHMETAFILE hemf;
        HBITMAP         bitmap;
        HDC             memDC;
        ENHMETAHEADER   emh;


        emf = ::GetEnhMetaFile(strFileName);


        // Get the header from the enhanced metafile.
        ZeroMemory( &emh, sizeof(ENHMETAHEADER) );
        emh.nSize = sizeof(ENHMETAHEADER);
        if( GetEnhMetaFileHeader( hemf, sizeof( ENHMETAHEADER ), &emh )
== 0 )
        {
                DeleteEnhMetaFile( hemf );
                return FALSE;
        }


        RECT    rect;
                float fAspectRatio;


        long lWidth,lHeight;
        long xFrame, yFrame;


        lWidth = ((long)((float)(emh.rclFrame.right -
emh.rclFrame.left) /
(100.0f))) * Scale;
        lHeight = ((long)((float)(emh.rclFrame.bottom -
emh.rclFrame.top) /
(100.0f))) * Scale;


        lWidth = lWidth * DeviceHorzPixelsPerMM;
        lHeight = lHeight * DeviceVertPixelsPerMM;


        View****tWidth = View****tWidth * DeviceHorzPixelsPerMM;
        View****tHeight = View****tHeight * DeviceVertPixelsPerMM;


        if((View****tWidth < lWidth)  || (View****tHeight < lHeight))
        {
                if((lWidth/lHeight) == 1)
                {
                        xFrame = min(View****tWidth, View****tHeight);
                        yFrame = min(View****tWidth, View****tHeight);
                }
                else
                {
                        fAspectRatio = (float)lWidth/(float)lHeight;
                        if(fAspectRatio > 1 ) //width is more than
height
                        {
                                xFrame = View****tWidth;
                                yFrame = (long)((float)View****tHeight /
fAspectRatio);
                        }
                        else //width is less than height(or equal to
height)
                        {
                                yFrame = View****tHeight;
                                xFrame = (long)((float)View****tWidth *
fAspectRatio);
                        }
                }
        }
        else
        {
                xFrame = lWidth;
                yFrame = lHeight;
        }
        lWidth = xFrame;
        lHeight = yFrame;
        - - - - -


}


Then I create BMP with lWidht X lHeight pixels which in case of printer

comes very high. 

Thanks for any help.
 




 1 Posts in Topic:
BMP image scaling and Printer resolution
jalpa11@[EMAIL PROTECTED]  2007-01-02 20:18:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 15:25:43 PST 2009.