成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

怎么在C#中利用SDL2實(shí)現(xiàn)一個(gè)視頻播放窗口截圖-創(chuàng)新互聯(lián)

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

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

具體方法如下

 /// <summary>
 /// SDL2截圖操作類
 /// </summary>
 public unsafe class SDLScreenshot
 {
  IntPtr window;// 窗口對(duì)象
  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實(shí)現(xiàn)一個(gè)視頻播放窗口截圖-創(chuàng)新互聯(lián)
鏈接URL:http://jinyejixie.com/article14/pspge.html

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

廣告

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

網(wǎng)站優(yōu)化排名
台安县| 峡江县| 赤壁市| 江永县| 景宁| 连江县| 松阳县| 宝山区| 抚远县| 抚远县| 万盛区| 商丘市| 嘉义市| 石首市| 花莲县| 鹰潭市| 中西区| 扬州市| 邵阳市| 临夏市| 宁安市| 正阳县| 昌江| 天峨县| 土默特左旗| 佛教| 晋江市| 平武县| 彭山县| 商水县| 石渠县| 通城县| 大田县| 隆尧县| 祁连县| 榆中县| 秀山| 福贡县| 景泰县| 历史| 广元市|