نمایش نتایج 1 تا 13 از 13

نام تاپیک: کد نویسی به روش Double Buffering

Threaded View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #1
    کاربر دائمی آواتار habibb
    تاریخ عضویت
    خرداد 1388
    محل زندگی
    قُلْ هُوَ اللَّهُ أَحَدٌ
    پست
    423

    Post کد نویسی به روش Double Buffering

    مهمترین اصل در ساخت گرافیک بازی های رایانه ای با #C

    دابل بافرینگ _Double Buffering



    چگونه یک فرم را دابل بافرینگ کنم
    فرمی که یک کنترل در حال حرکت است
    تا لرزش و چشمک زدن تصویر و لکه هایی که روی تصویر پس زمینه از کنترل در حال حرکت به جا می ماند از بین برود ؟
    اگر در هنگام اجرای برنامه و مشاهده ی حرکت کنترل ها در فرم ، با موس ، نوار عنوان بالای فرم را بگیریم.
    شاید برایتان پیش آمده باشد که : نمی توانیم نوار عنوان بالای فرم را گرفته و حرکت بدهیم !
    علتش اینست که توابع اجرا شده ی ما دارند در فرم ترسیم می شوند . بنابراین فرم غیر قابل حرکت می شود
    و توابع اجرایی تمام cpu سیستم را اشغال می کنند. و جابجایی کنترل ها که به سرعت در حرکتند نیز دیده می شود
    در نتیجه چشمک زدن ، لرزش ، پرش زدن تصویر یا به اصطلاح Flicker دیده می شود .
    و آن لکه هایی که جای مکان قبلی کنترل در حال حرکت ، داخل صفحه ی فرم بود پاک نشده
    و مسیر حرکت کنترل به شکل خطوط نامنظم ، تمام صفحه را خطخطی می کند.
    و رد مسیر کنترل در حال حرکت دیده می شود .
    به همین علت تمام نرم افزار های پیچیده ی گرافیکی نیاز دارند تا ترسیم هایشان ، اول از همه داخل بافر کشیده شود
    و بعد از این که خروجی آماده شد .
    خروجی را به فرم و صفحه نمایش منتقل کنند تا ما ترسیم های اضافی را نبینیم .
    بلکه ترسیم های لازم و زیبا ببینیم .





    Double Buffered Graphics


    NET Framework 4.5
    Flicker is a common problem when programming graphics. Graphics operations that require multiple complex painting operations can cause the rendered images to appear to flicker or have an otherwise unacceptable appearance. To address these problems, the .NET Framework provides access to double buffering.
    Double buffering uses a memory buffer to address the flicker problems associated with multiple paint operations. When double buffering is enabled, all paint operations are first rendered to a memory buffer instead of the drawing surface on the screen. After all paint operations are completed, the memory buffer is copied directly to the drawing surface associated with it. Because only one graphics operation is performed on the screen, the image flickering associated with complex painting operations is eliminated.


    Default Double Buffering


    The easiest way to use double buffering in your applications is to use the default double buffering for forms and controls that is provided by the .NET Framework. You can enable default double buffering for your Windows Forms and authored Windows controls by setting the DoubleBuffered property to true or by using the SetStyle method. For more information, see How to: Reduce Graphics Flicker with Double Buffering for Forms and Controls.


    Manually Managing Buffered Graphics


    For more advanced double buffering scenarios, such as animation or advanced memory management, you can use the .NET Framework classes to implement your own double-buffering logic. The class responsible for allocating and managing individual graphics buffers is the BufferedGraphicsContext class. Every application domain has its own default BufferedGraphicsContext instance that manages all of the default double buffering for that application. In most cases there will be only one application domain per application, so there is generally one default BufferedGraphicsContext per application. Default BufferedGraphicsContext instances are managed by the BufferedGraphicsManager class. You can retrieve a reference to the default BufferedGraphicsContext instance by calling the BufferedGraphicsManager.Current Property. You can also create a dedicated BufferedGraphicsContext instance, which can improve performance for graphically intensive applications. For information on how to create a BufferedGraphicsContext instance, see How to: Manually Manage Buffered Graphics.


    Manually Displaying Buffered Graphics


    You can use an instance of the BufferedGraphicsContext class to create graphics buffers by calling the BufferedGraphicsContext.Allocate Method, which returns an instance of the BufferedGraphics class. A BufferedGraphics object manages a memory buffer that is associated with a rendering surface, such as a form or control.
    After it is instantiated, the BufferedGraphics class manages rendering to an in-memory graphics buffer. You can render graphics to the memory buffer through the BufferedGraphics.Graphics Property, which exposes a Graphics object that directly represents the memory buffer. You can paint to this Graphics object just as you would to a Graphics object that represents a drawing surface. After all the graphics have been drawn to the buffer, you can use the BufferedGraphics.Render Method to copy the contents of the buffer to the drawing surface on the screen.
    For more information on using the BufferedGraphics class, see Manually Rendering Buffered Graphics. For more information on rendering graphics, see Graphics and Drawing in Windows Forms
    آخرین ویرایش به وسیله habibb : جمعه 07 تیر 1392 در 08:16 صبح دلیل: درج نکات و ویرایش متن

تاپیک های مشابه

  1. سوال: متد نیتیو، کاربرد استاتیک و Double Buffering
    نوشته شده توسط ehsangerrard در بخش برنامه‌نویسی جاوا
    پاسخ: 4
    آخرین پست: دوشنبه 13 تیر 1390, 20:50 عصر
  2. کد نویسی یا روش های دیگر ؟ (برای کار با database)
    نوشته شده توسط jas1387 در بخش C#‎‎
    پاسخ: 19
    آخرین پست: دوشنبه 09 فروردین 1389, 14:52 عصر
  3. مشکل با double buffered
    نوشته شده توسط Delphi-Man در بخش مباحث عمومی دلفی و پاسکال
    پاسخ: 19
    آخرین پست: پنج شنبه 16 مهر 1388, 22:51 عصر
  4. کسی میدونه Double Buffering در دلفی چطور کار می کنه
    نوشته شده توسط interrupt21 در بخش برنامه نویسی در Delphi
    پاسخ: 1
    آخرین پست: چهارشنبه 06 اردیبهشت 1385, 12:09 عصر
  5. Double Buffer
    نوشته شده توسط BAHMAN_SH در بخش برنامه نویسی با زبان C و ++C
    پاسخ: 3
    آخرین پست: جمعه 06 شهریور 1383, 04:20 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •