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); }
查看全文
相关阅读:
八字案例董易奇
nginx和tomcat二合一服务器配置SSL证书
RecyclerView,内容不居中的解决办法。
cxf接口生成WSDL带密码的code实践
去除server.key的密码
Window下openssl的安装教程(通俗易懂)
Nginx配置https证书
自己做CA
自己生成ssl证书
自己制作ssl证书:自己签发免费ssl证书,为nginx生成自签名ssl证书
原文地址:https://www.cnblogs.com/javawebsoa/p/2458418.html
最新文章
springmvc 校验,新增,及在输入页面报错 command找不到bean的原因。
SpringMVc 随笔3 ,注解入参pathVariable,requestparam,和modelAttributes和返回值,modelAndView,map
Eclipse 快捷键 及其 xsd dtd配置本地约束
mybaits 批量插入,及其测试。
(推荐)(全)集成maven,spring,springmvc,mybaits,ehcache,没有shiro。maven坐标全,xml配置文件全,
eclipse安装spring插件的几个问题,导入pom备份时的问题
centos 7 ,8 安装samba一般步骤,解决用户名密码无法登录的问题,解决ntlm和lanman访问限制
Mybatis 笔记2 一般步骤
Mybatis 接口编程 笔记1
centos6,安装samba
热门文章
web.xml不同版本的头
maven坐标较全 maven下的shiro的demo1,数据库查询用户
尚硅谷SSM的maven引入的jar。
spring ,springMVC,shiro 框架搭建。
(推荐)springmvc 随笔2,注解@RequestMapping,@PathVariable,@Param,ModelAndView,
springmvc 随笔1 quickstart
Mybaits 笔记1,接口编程,缺少resources目录
(推荐)maven 准备,快捷键,补全目录,引入dtd约束,ehcache的xsd约束,复制时提示context重名问题。
SSM 项目笔记,引入jar包
maven在引入jar包时,控制台报错的处理
Copyright © 2011-2022 走看看