画图,图像显示有抖动,更新后才能看见

来自中国的朋友,欢迎您在本版面使用中文讨论问题。请注意,如果您想得到不懂中文的人的帮助,请同时提供英文译文。
Help and discussions in Chinese.
Post Reply
liqi98136
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm

画图,图像显示有抖动,更新后才能看见

Post by liqi98136 »

画图,图像显示有抖动,更新后才能看见
为什么?

Code: Select all

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
import "ecere"
 
class Form1 : Window
{
   text = "Form1";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 576, 432 };

   void OnRedraw(Surface surface)
   {
          
          HDC hdc;
          //PAINTSTRUCT ps;
          const POINT polygon[10] = { 30, 145, 85, 165, 105, 110, 65, 125, 30, 105 }; 
          const POINT bezier[4] = {280, 160, 320, 160, 325, 110, 350, 110};
          
          
          
          hdc =GetDC(surface.GetDisplay().systemWindow);
          //hdc=BeginPaint(surface.GetDisplay(), &ps);
          Ellipse(hdc, 50, 50, 120, 90); 
       
          RoundRect(hdc, 150, 30, 240, 90, 15, 20); 
          Chord(hdc, 270, 30, 360, 90, 270, 45, 360, 45); 
          Polygon(hdc, polygon, 5);
          Rectangle(hdc, 150, 110, 230, 160);
          PolyBezier(hdc, bezier, 4);
          //EndPaint(surface.GetDisplay(), &ps); 
   }
}

Form1 form1 {};
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: 画图,图像显示有抖动,更新后才能看见

Post by jerome »

liqi,

Ecere is meant for writing cross-platform software, that will run as well on Linux as on Windows.

It doesn't support using the GDI.

Ecere has its own display buffer that it will copy to the screen and overwrite whatever you draw to the window.

If you really wanted to do this, you would need to know about the internal of the Ecere GDI driver implementation:

Code: Select all

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
import "ecere"
 
class GDISurface : LFBSurface { HDC hdc; }
 
class Form1 : Window
{
   text = "Form1";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 576, 432 };
 
   void OnRedraw(Surface surface)
   {
       const POINT polygon[10] = { { 30, 145 }, { 85, 165 }, { 105, 110 }, { 65, 125 }, { 30, 105 } }; 
       const POINT bezier[4] = { { 280, 160 }, { 320, 160 }, { 325, 110 }, { 350, 110 } };
       GDISurface gdiSurface = (GDISurface)surface.driverData;
       HDC hdc = gdiSurface.hdc;
       Ellipse(hdc, 50, 50, 120, 90); 
       RoundRect(hdc, 150, 30, 240, 90, 15, 20); 
       Chord(hdc, 270, 30, 360, 90, 270, 45, 360, 45); 
       Polygon(hdc, polygon, 5);
       Rectangle(hdc, 150, 110, 230, 160);
       PolyBezier(hdc, bezier, 4);
   }
}
 
Form1 form1 {};
Cheers,

Jerome
Post Reply