How to equivalence zoom image

zhaozj2021-02-08  216

How to equivalence zoom image

Author: Xu Jing Zhou

How can I best maintain an image protocol ratio when magnifying or narrowing an image? The following is provided to help you implement, then the rectangular area returned, the rectangular area returns is the best display image size.

l The first parameter rcscreen in the macout is the rectangle size of the image to be displayed. The second parameter sizePicture is the image itself, the third parameter bceter is displayed in the case, and the return value CRECT is only the image optimal display size.

The description is as follows:

CRECT RectSizewithConstantratio (CRECT * RCSCREEN,

CSIZE SIZEPICTURE,

Bool bcenter)

{

CRECT Rect (rcscreen);

Double dwidth = rcscreen-> width ();

Double DHEIGHT = rcscreen-> height ();

Double daspectratio = dwidth / dheight;

Double DPICTUREWIDTH = SIZEPICTURE.CX;

Double DPICTUREHEIGHT = SIZEPICTURE.CY;

Double DPICTureaspectratio = DPICTUREWIDTH / DPICTUREHEIGHT;

// if the aspect ratios are the Same dam Rectangle

// Will Do, Otherwise We need to Calculate the New Rectangle

IF (DPICTureaspectratio> Daspectratio)

{

INT nnewheight = (int) (dwidth / dpicturewidth * dpictureheight);

INT ncenteringfactor = (rcscreen-> height () - nnewheight) / 2;

Rect.seTRect (0,

NcenteringFactor,

(int) DWIDTH,

NNEWHEIGHT NCENTERINGFACTOR);

}

ELSE IF (DPictureAspectratio

{

INT nnewwidth = (int) (DHEIGHT / DPICTUREHEIGHT * DPICTUREWIDTH);

INT NCENTERINGFACTOR = (rcscreen-> width () - nnewwidth/2;

Rect.seTRect (ncenteringfactor,

0,

NNewWidth NcenteringFactor,

(INT));

}

RETURN RECT;

}

Contact information:

Email: jingzhou_xu@163.com

Future Studio (Future Studio)

转载请注明原文地址:https://www.9cbs.com/read-2107.html

New Post(0)