2013-02-06 5 views
0

Kinect를 사용하여 실시간으로 실행되는 비디오에서 bmp 파일을 만들려고합니다. 이미지 상단에 라이브 비디오를 실행하는 응용 프로그램을 개발 중입니다. 내가 사용하고있는 IDE는 Visual Studio Professional 2010입니다. Win32를 사용하여 C++로 개발할 코드입니다.
. 오버레이 된 이미지와 함께 비디오를 저장하고 싶습니다. 이제 오버레이 방식으로 비트 맵을 표시하기 위해 ID2D1Bitmap을 사용하고 있습니다. 하지만 오버레이 된 이미지가있는 비디오에서 바이트 * 데이터를 검색해야합니다. ID2D1Bitmap에서 바이트 * 데이터를 검색하는 bmp 파일을 만들려고합니다. 그러나 직접 변환은 바이트 * 데이터를 검색 할 수 없습니다.ID2D1Bitmap에서 bmp 파일을 저장하는 방법

  m_pd2d1RenderTarget->DrawBitmap(m_pd2d1Bitmap_Image,D2D1::Rect(120,140, 120+Height,140+Width)); 
      m_pd2d1RenderTarget->DrawBitmap(m_pd2d1Bitmap_Video); 

    I copied the data to the ID2D1Bitmap using the function called, 
      m_pd2d1RenderTarget->CopyFromMemory(NULL,pvideo_Data,video_Info.bmWidthBytes); m_pd2d1RenderTarget->CopyFromMemory(NULL, pBitmap_Data,Bitmap_Info.bmWidthBytes); 

하지만 이제는 두 비트 맵을 결합하여 그 바이트 데이터를 가져 오려고합니다. 비트 맵을 byte *로 변환 할 수 있습니까? 그것은 직접 변환 ID2D1Bitmap ???에서 바이트 * 데이터를 얻을 수 있습니까? 또한 ID2D1Bitmap을 IWICBitmap으로 변환하려고합니다. IWICBitmap-> Lock을 사용하면 바이트 * 내용을 검색 할 수 있기 때문입니다. 그러므로 다음과 같은 의심에 빠지게 도와 주시고 귀중한 지침을주십시오 :

1. ID2D1Bitmap을 byte *로 변환 하시겠습니까?

2. ID2D1Bitmap을 IWICBitmap으로 변환하는 방법. 사전 :

감사에서

감사합니다,

VVK.

+0

귀하의 필요에 맞는 답변을 수락하거나 추가 지원이 필요한 경우 명확히 설명해주십시오. – Sekkou527

답변

0

나는 이것을 C#에서 다음과 같이했다. 우리가 작성한 코드는 프레임의 바이트 배열을 캡처 이미지 형식을 만들고, 아래의 기능에서 비트 맵 형식으로 변환 한 다음 나중에 파일 시스템에 저장하기위한 압축 된 JPEG로 저장합니다

using (DepthImageFrame depthFrame = e.OpenDepthImageFrame()) 
       { 
        if (depthFrame == null) return; 
        byte[] pixels = GenerateColoredBytes(depthFrame, first); 

        int stride = depthFrame.Width * 4; 
        depthImage.Source = BitmapSource.Create(depthFrame.Width, depthFrame.Height, 96, 96, PixelFormats.Bgr32, null, pixels, stride); 

        Bitmap btmap = GetBitmap((BitmapSource)depthImage.Source); 

        // Encoder parameter for image quality 
        long quality = 100000; 
        EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality); 
        // Jpeg image codec 
        ImageCodecInfo jpegCodec = getEncoderInfo("image/jpeg"); 
        EncoderParameters encoderParams = new EncoderParameters(1); 
        encoderParams.Param[0] = qualityParam; 

        var stream = new MemoryStream(); // Create MemoryStream 
        btmap.Save(stream, jpegCodec, encoderParams); //(stream, ImageFormat.Jpeg); // Save Bitmap as .jpeg in MemoryStream      

        depthPath = "_UserTrialImages/" + UsernameInput.username + "/Date-" + DateTime.Now.ToString("MM.dd.yyyy"); 
        gamePath = depthPath + "/Game-" + gameNumber; 
        trajectoryPath = gamePath + "/Trajectory-" + trajectoryNumber;  // one trajectory per super bubble appearance 

        string depthFile = "image" + ind[5] + ind[4] + ind[3] + ind[2] + ind[1] + ind[0] + ".jpg"; 
        string pathFile = trajectoryPath + '/' + depthFile; 

        imageNumberCounter(); 
        newImg.pathFile = pathFile; 
        newImg.stream = stream; 

        // saves depth images in list 
        listOfImages.Add(newImg); 
       } 

이를 호출 기능 :

Bitmap GetBitmap(BitmapSource source) 
{ 
    Bitmap bmp = new Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); 

    BitmapData data = bmp.LockBits(
     new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), 
     ImageLockMode.WriteOnly, 
     System.Drawing.Imaging.PixelFormat.Format32bppPArgb); 

    source.CopyPixels(
     Int32Rect.Empty, 
     data.Scan0, 
     data.Height * data.Stride, 
     data.Stride); 

    bmp.UnlockBits(data); 

    return bmp; 
} 

나는 C++이없는,하지만 당신은 .NET 4.0에서 코딩하는 경우, C++에서 위와 같이 동일한 작업을 수행합니다 동등한 기능이 있어야한다. 희망이 도움이됩니다.

관련 문제