zoukankan
html css js c++ java
VC 和 GDI+ 实现仿ibook 翻页效果
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 pen(Color::Black);//设置画笔 SolidBrush brush(Color::Black);//设置画刷 //设置输出字体 FontFamily fontfamily(L"微软雅黑"); Font font(&fontfamily,12,FontStyleRegular,UnitPoint); StringFormat strfmt; RectF 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,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 *a)); float calculated_y = (m_x) * (tan(radians)); float calculated_x = 0; GraphicsPath gpLeft,gpRight; //////////////////////////////////////////////////////////////////2 if (calculated_y < height) { 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); }
查看全文
相关阅读:
面试题6:用两个栈实现队列
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062: 解决办法
支付系统的对账处理与设计--转
centos 6.7下安装rabbitmq 3.6.6过程
Can't access RabbitMQ web management interface after fresh install
Spring Cloud Netflix Eureka client源码分析
spring cloud config配置中心源码分析之注解@EnableConfigServer
量化派基于Hadoop、Spark、Storm的大数据风控架构--转
Inversion of Control Containers and the Dependency Injection pattern--Martin Fowler
spark groupByKey 也是可以filter的
原文地址:https://www.cnblogs.com/javawebsoa/p/2458418.html
最新文章
ESMOD北京高级时装艺术学校_百度百科
ESMOD北京高级时装艺术学校_百度百科
服装制版和推版到底有什么区别啊?_百度知道
string 到 wstring的转换
wchar_t 、UTF-8、UTF-16的转换方法
兴隆公园_百度百科
How to convert string to wstring?
数据结构~总结与文章目录
Lind.DDD.IoC(大叔推荐)~在服务定位器中引入IoC容器~容器的适配器
Lind.DDD.Manager里菜单权限的设计
热门文章
技巧~向URL地址添加参数
EF架构~CodeFirst数据迁移与防数据库删除
删除带.的文件夹
hdu1257(最少拦截系统 )
Activity的创建和使用
Poj 3246 Balanced Lineup(线段树基础)
打印从1到最大的n位数
urlrewrite 匹配规则之优先选择
HDU 3336 Count the string KMP
Oracle 11g RAC OCR 与 db_unique_name 配置关系 说明
Copyright © 2011-2022 走看看