Microsoft MVP성태의 닷넷 이야기
C# SharpDX 화면 캡쳐 관련해서 질문 드립니다. [링크 복사], [링크+제목 복사],
조회: 13258
글쓴 사람
이완호 (dldhksgh90 at naver.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

                        _device.ImmediateContext.CopyResource(textureResource, d3d11Texture2D);
                        DataBox mapSource = _device.ImmediateContext.MapSubresource(d3d11Texture2D, 0, MapMode.Read, SharpDX.Direct3D11.MapFlags.None);
                        Bitmap bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                        Rectangle bounds = new Rectangle(0,0, desktopBounds.Width, desktopBounds.Height);
                        BitmapData mapDest = bitmap.LockBits(bounds, System.Drawing.Imaging.ImageLockMode.WriteOnly, bitmap.PixelFormat);
                        var sourcePtr = mapSource.DataPointer;
                        var destPtr = mapDest.Scan0;

                        for (int y = 0; y < height; y++)
                        {

                            Utilities.CopyMemory(destPtr, sourcePtr, width * 4);
                            sourcePtr = IntPtr.Add(sourcePtr, mapSource.RowPitch);
                            destPtr = IntPtr.Add(destPtr, mapDest.Stride);
                        }
                        

                        createBitmap(bitmap);
                        bitmap.UnlockBits(mapDest);

해당 코드를 통해 Bitmap 을 생성하고


                    EncoderParameters myEncoderParameters = new EncoderParameters(1);
                    myEncoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 80L);
                    sendImage.Save(memory, GetEncoder(ImageFormat.Jpeg), myEncoderParameters);

생성된 비트맵을 버퍼로 뽑아내어 소켓을 통해 송수신 받습니다.
여기서 System.Drawing.Bitmap에서 MemoryStream으로 변환하는 과정의 소요시간을 줄이고 싶습니다.

그렇기에 SharpDX.Direct2D1.Bitmap 으로 만들었을 경우 네트워크 송수신을 위해 메모리스트림을 통해 더욱 적은 용량의 버퍼로 변환하는 방법이 있을까요 ?





[연관 글]






[최초 등록일: ]
[최종 수정일: 12/17/2021]


비밀번호

댓글 작성자
 



2021-12-18 12시44분
그러면, 애당초 Utilities.CopyMemory의 루프에서 JPG 데이터를 구성하는 것이 더 좋지 않을까요? 물론, 그것을 위해서는 적절한 JPEG 라이브러리를 쓰시는 것이 좋을 듯합니다.

사실, 화면 캡쳐를 연속으로 뜰 것이라면 일종의 동영상이라고 봐야 합니다. 그렇다면 동영상 코덱을 적용해 보는 것도 나쁘진 않을 것입니다. 가령, 아래의 프로젝트가 그런 식으로 작성된 것입니다.

akon47/ScreenRecorder
; https://github.com/akon47/ScreenRecorder

(업데이트: 2021-12-22)

아래의 글을 참고하세요.

C# - (SharpDX + DXGI) 화면 캡처한 이미지를 빠르게 JPG로 변환하는 방법
; https://www.sysnet.pe.kr/2/0/12889
정성태

... 76  77  78  79  80  81  82  83  84  85  86  87  88  89  [90]  ...
NoWriterDateCnt.TitleFile(s)
211류성태6/15/200510390smart client에 관하여.... [1]
206헤커의작...6/14/20059413[질문] 안녕하세요. 성태님의 홈페이지에서 화면전환시 처리되는 것에 관련된 건 [3]
205김종욱 6/12/20059910com+ 에서 서버 소켓을 열고 싶고요... com+에서 thread는 어떻게 돌리는지 알고 싶습니다
209정성태6/14/20059916    답변글 [답변]: com+에서 서버 소켓을 열고 싶고요... com+에서 thread는 어떻게 돌리는지 알고 싶습니다
204정현일6/9/200510084Smart Client 실행시 SecurityException파일 다운로드1
208정성태6/14/200510558    답변글 [답변]: Smart Client 실행시 SecurityException [1]
203나그네6/9/200510287태오 사이트 Smart Client 강좌중에서요
207정성태6/14/20059936    답변글 [답변]: 태오 사이트 Smart Client 강좌중에서요
210나그네6/15/200510112        답변글 [답변]: [답변]: 태오 사이트 Smart Client 강좌중에서요파일 다운로드1
198이지훈6/2/200594242003이랑 2005랑 함께 사용하는 방법이 없을까요?
201정성태6/6/20059951    답변글 [답변]: 2003이랑 2005랑 함께 사용하는 방법이 없을까요?
197이지훈6/2/2005101152005 에서 컴포넌트 제작
200정성태6/6/20059617    답변글 [답변]: 2005 에서 컴포넌트 제작
196김종욱5/24/200510792익스플러 툴 벤드 제작... for .NET [1]파일 다운로드1
199정성태6/6/200510255    답변글 [답변]: 익스플러 툴 벤드 제작... for .NET
202김종욱6/9/200510692        답변글 [답변]: [답변]: 익스플러 툴 벤드 제작... for .NET [1]
194홍지철5/18/20059985IE에서 Winform control embedded작성시 문제점
195정성태5/19/200510567    답변글 [답변]: IE에서 Winform control embedded작성시 문제점
192헤헤5/13/200510180이것좀봐주세요
193정성태5/13/20059310    답변글 [답변]: 이것좀봐주세요
186기범5/9/20059907안녕하세요2
187정성태5/9/200510272    답변글 [답변]: 안녕하세요2
184기범5/9/20059797안녕하세요
185정성태5/9/200510173    답변글 [답변]: 안녕하세요
1815/8/20059780// 꼭쫌 답변해 주세요~~~클라이언트 서버 ... 내용, 이점 들...
183정성태5/9/20059443    답변글 [답변]: // 꼭쫌 답변해 주세요~~~클라이언트 서버 ... 내용, 이점 들...
... 76  77  78  79  80  81  82  83  84  85  86  87  88  89  [90]  ...