Implement iBook-like paging through VC and GDI +

Source: Internet
Author: User

 
Void cgdiplustestview: ondraw (CDC * PDC)
{
Cgdiplustestdoc * pdoc = getdocument ();
Assert_valid (pdoc );
// Todo: Add draw code for native data here
// Device context for painting

CDC dcmemory;
Dcmemory. createcompatibledc (null );
Crect bkrect;
Getclientrect (& bkrect );
Cbitmap bitmap;
Bitmap. createcompatiblebitmap (PDC, bkrect. Width (), bkrect. Height ());
SelectObject (dcmemory. getsafehdc (), bitmap );

Topframe = (bkrect. Height ()-height)/2;
Leftframe = (bkrect. Width ()-2 * width)/2;

Image
L1image (L "pages/1.jpg", false ),
L2image (L "pages/2.jpg", false ),
L3image (L "pages/1.jpg", false ),
L4image (L "pages/2.jpg", false );

Graphics graphics (dcmemory. m_hdc );

Graphics. drawimage (& l1image, leftframe, topframe, width, height );
Graphics. drawimage (& l2image, leftframe + width, topframe, width, height );

Pen (color: Black); // you can specify a paint brush.

Solidbrush brush (color: Black); // you can specify a paint brush.

// Set the output font

Fontfamily (L "");

Font font (& fontfamily, 12, fontstyleregular, unitpoint );

Stringformat strfmt;

Rectf (leftframe + 25, topframe + 25,280,400 );
Rectf rectf2 (leftframe + 50 + width, topframe + 25,280,450 );
Rectf rectf3 (0, 0,280,450 );
 
Color clrpen (0, 0, 0 );
Pen pendraw (clrpen, 0 );

Graphics. drawstring (context, 1024, & font, rectf, & strfmt, & brush );
Graphics. drawstring (context, 1024, & font, rectf2, & strfmt, & brush );

Float undersideoffset = width;
Double A = 45 + (45 * m_x)/width;
Double radians = A * (3.14/180.0 );
Double pageundersiderotationangle = (180-(2 * ));
Float calculated_y = (m_x) * (TAN (radians ));
Float calculated_x = 0;

Graphicspath gpleft, gpright;
//////////////////////////////////////// /// // 2
If (calculated_y {
Gpleft. addline (pointf (ABS (width-m_x + undersideoffset), height), pointf (width + undersideoffset, height ));
Gpleft. addline (pointf (width + undersideoffset, height), pointf (width + undersideoffset, (height-(float) calculated_y )));
} Else
{
Gpleft. addline (pointf (ABS (width-m_x + undersideoffset), height), pointf (width + undersideoffset, height ));
Gpleft. addline (pointf (width + undersideoffset, height), pointf (width + undersideoffset, 0 ));
Calculated_x = height/TAN (radians );
Gpleft. addline (pointf (width + undersideoffset, 0), pointf (ABS (width-(m_x-(float) calculated_x) + undersideoffset), 0 ));
}


Gpleft. closefigure ();

Matrix pathtranslationmatrix;
Pathtranslationmatrix. Translate (float) leftframe, (float) topframe );
Gpleft. Transform (& pathtranslationmatrix );

Region oldregion;
Graphics. getclip (& oldregion );

Graphics. setclip (& gpleft );
 
Graphics. drawpath (& pendraw, & gpleft );
Graphics. drawimage (& l4image, leftframe + width, topframe, width, height );

Graphics. setclip (& oldregion );
//////////////////////////////////////// /// // 3
Bitmap pageundersideimage (width, height );
Undersideoffset = width;
// If (height <calculated_y)
{
Gpright. addline (pointf (ABS (width-m_x-undersideoffset), height ),
Pointf (width-undersideoffset, height ));
Gpright. addline (pointf (width-undersideoffset, height ),
Pointf (width-undersideoffset,
(Height-(float) calculated_y )));
}/* Else
{
Gpright. addline (pointf (ABS (width-m_x-undersideoffset), height), pointf (width-undersideoffset, height ));
Gpright. addline (pointf (width-undersideoffset, height), pointf (width-undersideoffset, 0 ));
Calculated_x = height/TAN (radians );
Gpright. addline (pointf (width-undersideoffset, 0), pointf (ABS (width-(m_x-(float) calculated_x)-undersideoffset), 0 ));
}*/

Gpright. closefigure ();
Graphics UG (& pageundersideimage );
Ug. setclip (& gpright );
Ug. drawpath (& pendraw, & gpright );
Ug. drawimage (& l3image, 0, 0, width, height );
Ug. drawstring (context, 1024, & font, rectf3, & strfmt, & brush );


Matrix pathtranslationmatrix1;
Pathtranslationmatrix1.translate (leftframe + width * 2-m_x, topframe + height );

Pathtranslationmatrix1.rotate (float) (pageundersiderotationangle ));

Graphics. settransform (& pathtranslationmatrix1 );
Graphics. drawimage (& pageundersideimage,-int (m_x),-height, width, height );

 

PDC-> bitblt (0, 0, bkrect. Width (), bkrect. Height (), & dcmemory, 0, 0, srccopy );

Graphics. releasehdc (dcmemory. m_hdc );


}

Implement iBook-like paging through VC and GDI +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.