<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 怎么在C#中利用SDL2實現(xiàn)一個視頻播放窗口截圖-創(chuàng)新互聯(lián)

            本篇文章給大家分享的是有關(guān)怎么在C# 中利用SDL2實現(xiàn)一個視頻播放窗口截圖,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

            創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比新建網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式新建網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋新建地區(qū)。費用合理售后完善,十載實體公司更值得信賴。

            具體方法如下

             /// <summary>
             /// SDL2截圖操作類
             /// </summary>
             public unsafe class SDLScreenshot
             {
              IntPtr window;// 窗口對象
              IntPtr renderer;// 播放窗口的渲染器(來自于已初始化的播放窗口渲染器) 
              public SDLScreenshot(IntPtr window, IntPtr renderer)
              {
               this.window = window;
               this.renderer = renderer;
              } 
              /// <summary>
              /// 保存截圖
              /// </summary>
              /// <param name="width"></param>
              /// <param name="height"></param>
              /// <param name="path"></param>
              public void SaveBMP(int width, int height,string path)
              {
               // 判斷渲染器是否初始化
               if (renderer == IntPtr.Zero)
               {
                Console.WriteLine("renderer is null ,please call Init() method.");
                return;
               }
               uint Rmask=0x00FF0000, Gmask = 0x0000FF00, Bmask = 0x000000FF, Amask = 0x00000000;
               // 獲取圖像數(shù)據(jù)
               SDL.SDL_Surface* surface= (SDL.SDL_Surface*)SDL.SDL_CreateRGBSurface(0, width, height, 32, Rmask, Gmask, Bmask, Amask);
               //設(shè)置紋理的數(shù)據(jù)
               SDL.SDL_Rect destrect;
               destrect.x = 0;
               destrect.y = 0;
               destrect.w = width;
               destrect.h = height; 
             
               // 讀取并渲染圖像數(shù)據(jù)
               SDL.SDL_RenderReadPixels(renderer, ref destrect, SDL.SDL_PIXELFORMAT_ARGB8888, surface->pixels, surface->pitch); 
             
               //保存圖片
               int i = SDL.SDL_SaveBMP((IntPtr)surface, path);
               if (i != 0)
               {
                Console.WriteLine("screenshot failed." + SDL.SDL_GetError());
               } 
             
               SDL.SDL_FreeSurface((IntPtr)surface);
               //SDL.SDL_RenderClear(renderer);
               //SDL.SDL_DestroyRenderer(renderer); 
              } 
             
              /// <summary>
              /// 加載截圖
              /// </summary>
              /// <param name="width"></param>
              /// <param name="height"></param>
              /// <param name="path"></param>
              public void LoadBMP(int width, int height, string path)
              {
               // 判斷渲染器是否初始化
               if (renderer == IntPtr.Zero)
               {
                Console.WriteLine("renderer is null ,please call Init() method.");
                return;
               }
               // 加載圖片
               IntPtr surface = SDL.SDL_LoadBMP(path);
               if (surface == IntPtr.Zero)
               {
                Console.WriteLine("load bmp failed." + SDL.SDL_GetError());
                return;
               }
               IntPtr texture = SDL.SDL_CreateTextureFromSurface(renderer, surface);
               if (texture == IntPtr.Zero)
               {
                Console.WriteLine("create texture failed." + SDL.SDL_GetError());
                return;
               }
               SDL.SDL_FreeSurface(surface); 
             
               //設(shè)置紋理的數(shù)據(jù)
               SDL.SDL_Rect destrect;
               destrect.x = 0;
               destrect.y = 0;
               destrect.w = width;
               destrect.h = height; 
             
               SDL.SDL_Rect srcrect = destrect; 
             
               //SDL.SDL_RenderClear(renderer);
               SDL.SDL_RenderCopy(renderer, texture, ref srcrect, ref destrect);
               SDL.SDL_RenderPresent(renderer);
             
             
               //SDL.SDL_Delay(20); 
               SDL.SDL_DestroyTexture(texture);
               //SDL.SDL_DestroyRenderer(renderer);
               //SDL.SDL_DestroyWindow(screen);
               //Quit SDL 
               //SDL.SDL_Quit();
              }
             }

            分享標(biāo)題:怎么在C#中利用SDL2實現(xiàn)一個視頻播放窗口截圖-創(chuàng)新互聯(lián)
            鏈接URL:http://www.jbt999.com/article14/pspge.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站策劃、全網(wǎng)營銷推廣網(wǎng)站排名、移動網(wǎng)站建設(shè)

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

            網(wǎng)站優(yōu)化排名

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 欧美性受XXXX黑人XYX性爽ni | 小黄片在线马上播放 | 亚洲系列1| 欧美成人自拍视频 | 色婷婷五月天影院 |