设为首页 加入收藏

TOP

17.9.3 电子相册浏览模块的设计与实现(7)
2013-10-07 14:39:53 来源: 作者: 【 】 浏览:55
Tags:17.9.3 电子相册 浏览 模块 设计 实现

17.9.3  电子相册浏览模块的设计与实现(7)

所以对于封面翻页所需求的是页面2与页面1的路径,而左翻页到封底所需求的是页面2与页封底的路径。

  1. 01  if(m_turnType == type_head || m_turnType == type_rightToend)  
  2. 02  {  
  3. 03      GraphicsPath gpLeft,gpRight;  
  4. 04      int undersideOffset = width;  
  5. 05      if(m_turnType == type_head)         //封面翻页求页面2的路径  
  6. 06      {  
  7. 07          if(calculated_y < height)       //三角形时页面2的路径  
  8. 08          {  
  9. 09              gpLeft.AddLine( PointF(abs(width - m_x + undersideOffset),              height),  
  10. 10                          PointF(width + undersideOffset, height));  
  11. 11              gpLeft.AddLine( PointF(width + undersideOffset, height),  
  12. 12                          PointF(width + undersideOffset, (height –  
  13. 13                          (float)calculated_y)));  
  14. 14          }  
  15. 15          else                            //梯形时页面2的路径  
  16. 16          {  
  17. 17              gpLeft.AddLine(PointF(abs(width - m_x + undersideOffset),               height),  
  18. 18                              PointF(width + undersideOffset, height));  
  19. 19              gpLeft.AddLine(PointF(width + undersideOffset, height),  
  20. 20                              PointF(width + undersideOffset, 0));  
  21. 21              //绘制对称线  
  22. 22              calculated_x = height / tan(radians);   
  23. 23              gpLeft.AddLine( PointF(width + undersideOffset, 0),  
  24. 24                          PointF(abs(width - (m_x - (float)calculated_x) +  
  25. 25                                  undersideOffset), 0));  
  26. 26          }  
  27. 27          gpLeft.CloseFigure();  
  28. 28          Matrix PathTranslationMatrix;  
  29. 29          PathTranslationMatrix.Translate((float)m_photoFrameLeft,  
  30. 30                                      (float)m_photoFrameTop);  
  31. 31          gpLeft.Transform(&PathTranslationMatrix);   //原点平移  
  32. 32          Region oldRegion;  
  33. 33          g.GetClip(&oldRegion);  
  34. 34          g.SetClip(&gpLeft);                     //添加路径  
  35. 35          g.DrawPath(&penDraw,&gpLeft);           //绘制边框  
  36. 36          g.DrawImage(m_pPage[1],m_photoFrameLeft + m_pPage[1]-> 
  37.             GetWidth(),  
  38. 37                      m_photoFrameTop,m_pPage[1]->GetWidth(),  
  39. 38                      m_pPage[1]->GetHeight());   //绘制页面2  
  40. 39          g.SetClip(&oldRegion);                  //恢复原属性  
  41. 40      }  
  42. 41      else                                //右翻页到封底时求页面2的路径  
  43. 42      {  
  44. 43          if(calculated_y < height)       //三角形时页面2的路径  
  45. 44          {  
  46. 45              gpLeft.AddLine( PointF(width , 0), PointF( width , height) );  
  47. 46              gpLeft.AddLine( PointF( width , height),  
  48. 47                          PointF(abs(width - m_x + undersideOffset),   
  49.                             height));  
  50. 48              gpLeft.AddLine( PointF(abs(width - m_x + undersideOffset),   
  51.                 height),  
  52. 49                          PointF(width + undersideOffset,  
  53. 50                          (height - (float)calculated_y)));  
  54. 51              gpLeft.AddLine( PointF(width + undersideOffset,  
  55. 52                          (height - (float)calculated_y)),  
  56. 53                          PointF(width + undersideOffset, 0));  
  57. 54          }  
  58. 55          else                            //梯形时页面2的路径  
  59. 56          {  
  60. 57              gpLeft.AddLine(PointF(width, 0),PointF( width , height));  
  61. 58              gpLeft.AddLine(PointF( width , height) ,  
  62. 59                          PointF(abs(width - m_x + undersideOffset),   
  63.                             height));  
  64. 60    
  65. 61              calculated_x = height / tan(radians);   
  66. 62              gpLeft.AddLine( PointF(abs(width - m_x + undersideOffset),              height),  
  67. 63                          PointF(abs(width - (m_x - (float)calculated_x)+  
  68. 64                          undersideOffset), 0));  
  69. 65          }  
  70. 66          gpLeft.CloseFigure();  
  71. 67          Matrix PathTranslationMatrix;  
  72. 68          PathTranslationMatrix.Translate((float)m_photoFrameLeft,  
  73. 69                                  (float)m_photoFrameTop);  
  74. 70          gpLeft.Transform(&PathTranslationMatrix);   //平移坐标原点  
  75. 71          Region oldRegion;  
  76. 72          g.GetClip(&oldRegion);                      //保存原属性  
  77. 73          g.SetClip(&gpLeft);                         //添加路径  
  78. 74          g.DrawPath(&penDraw,&gpLeft);               //绘制边框  
  79. 75          g.DrawImage(m_pPage[1],m_photoFrameLeft + m_pPage[1]-> 
  80.             GetWidth(),  
  81. 76                      m_photoFrameTop,m_pPage[1]->GetWidth(),  
  82. 77                      m_pPage[1]->GetHeight());       //绘制界面2  
  83. 78          g.SetClip(&oldRegion);                      //恢复原属性  
  84. 79      }  
  85. 80      //创建临时画板  
  86. 81      Bitmap pageUndersideImage(width,height);          
  87. 82      undersideOffset =  width;  
  88. 83      if(calculated_y < height)                   //三角形时旋转区域大小  
  89. 84      {  
  90. 85          gpRight.AddLine( PointF(abs(width - m_x - undersideOffset),   
  91.             height),  
  92. 86                      PointF(width - undersideOffset, height));  
  93. 87          gpRight.AddLine( PointF(width - undersideOffset, height),  
  94. 88                      PointF(width - undersideOffset, (height - (float)  
  95.                         calculated_y)));  
  96. 89      }  
  97. 90      else                                        //梯形时旋转区域大小  
  98. 91      {  
  99. 92          gpRight.AddLine(PointF(abs(float(width) - m_x – underside-  
  100.             Offset),height),  
  101. 93                      PointF(width - undersideOffset, height));  
  102. 94          gpRight.AddLine(PointF(width - undersideOffset, height),  
  103. 95                      PointF(width - undersideOffset, 0));  
  104. 96    
  105. 97          calculated_x = height / tan(radians);   
  106. 98          gpRight.AddLine( PointF(width - undersideOffset, 0),  
  107. 99                      PointF(abs(width - (m_x - (float)calculated_x) –  
  108. 00                      undersideOffset), 0));  
  109. 101     }  
  110. 102     Graphics ug(&pageUndersideImage);  
  111. 103     ug.SetClip(&gpRight);  
  112. 104     ug.DrawPath(&penDraw,&gpRight);         //添加路径  
  113. 105     if(m_turnType == type_rightToend)           //右翻页到封底时绘制封底  
  114. 106     {  
  115. 107         ug.DrawImage(m_pPage[5], 0,0,m_pPage[1]->GetWidth(),  
  116. 108                     m_pPage[1]->GetHeight());  
  117. 109         Matrix PathTranslationMatrix1;  
  118. 110         PathTranslationMatrix1.Translate(m_photoFrameLeft +  
  119. 111                                     m_pPage[1]->GetWidth()*2 - m_x,  
  120. 112                                     m_photoFrameTop +  
  121. 113                                     m_pPage[1]->GetHeight());  
  122. 114         PathTranslationMatrix1.Rotate((float)(pageUndersideRotation-  
  123.             Angle ));  
  124. 115         g.SetTransform(&PathTranslationMatrix1);    //平移原点  
  125. 116         g.DrawImage(&pageUndersideImage, -int(m_x),-height ,width,  
  126.             height );  
  127. 117     }  
  128. 118     else                                        //首页翻页绘制图像1  
  129. 119     {  
  130. 120         ug.DrawImage(m_pPage[0], 0,0,m_pPage[1]->GetWidth(),  
  131. 121                     m_pPage[1]->GetHeight());  
  132. 122         Matrix PathTranslationMatrix1;  
  133. 123         PathTranslationMatrix1.Translate(m_photoFrameLeft +   
  134. 124                                 m_pPage[1]->GetWidth()*2 -  
  135. 125                                 m_x, m_photoFrameTop +  
  136. 126                                 m_pPage[1]->GetHeight());  
  137. 127         PathTranslationMatrix1.Rotate((float)(pageUndersideRotation-  
  138.             Angle ));  
  139. 128         g.SetTransform(&PathTranslationMatrix1);    //平移原点  
  140. 129         g.DrawImage(&pageUndersideImage, -int(m_x),-height ,width,  
  141.             height );  
  142. 130     }  
  143. 131 }  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇17.9.3 电子相册浏览模块的设计与.. 下一篇17.9.3 电子相册浏览模块的设计与..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: