Raw Image Data 
Author Message
 Raw Image Data

Can someone explain to me the methods used to copy an image buffer
containing YUY2 (YUYV) data to a DirectX 8 Surface. After DX7.1 I haven't
seen any way of getting direct access to the video memory of a surface. Then
again, they did away with my simple old DirectDraw routines. :-(

A VB6 example would be most helpful.

Thanks
Vincent DeCampo



Sun, 03 Oct 2004 04:46:47 GMT  
 Raw Image Data
cif the data is in the same format, copyrects is there.

if the formats are different, you can still lock a texture surface to get a
pointer to the bits.

from the VB doc:

Copying Surfaces
The term blit is shorthand for "bit block transfer," which is the process of
transferring blocks of data from one place in memory to another. The
blitting device driver interface (DDI) continues to be used in Microsoft?
DirectX? 8.x as the primary mechanism for moving large rectangles of pixels
on a per-frame basis, the mechanism behind the copy-oriented
Direct3DDevice8.Present method. The transportation of artwork in the blit
operation is performed by the Direct3DDevice8.UpdateTexture method. Artwork
can also be copied in DirectX 8.x by using the Direct3DDevice8.CopyRects
method, which copies a rectangular subset of pixels.

Note  Microsoft? Direct3DX functions enable you to load artwork from files,
apply color conversion, and resize artwork. For more information on the
available functions see the D3DX8.class and look under methods for textures.

Accessing Surface Memory Directly
You can directly access the surface memory by using the
Direct3DSurface8.LockRect method. When you call this method, the RECT
parameter is a RECT type that describes the rectangle on the surface to
access directly. To request that the entire surface be locked, set RECT to
Nothing. Also, you can specify a RECT that covers only a portion of the
surface. Providing that no two rectangles overlap, two threads or processes
can simultaneously lock multiple rectangles in a surface. Note that a
multisample back buffer cannot be locked.

The LockRect method fills a D3DLOCKED_RECT type with all the information to
properly access the surface memory. The structure includes information about
the pitch and has the locked bits. When you finish accessing the surface
memory, call the Direct3DSurface8.UnlockRect method to unlock it.

While you have a surface locked, you can directly manipulate the contents.
The following list describes some tips for avoiding common problems with
directly rendering surface memory.

  a.. Never assume a constant display pitch. Always examine the pitch
information returned by the LockRect method. This pitch can vary for a
number of reasons, including the location of the surface memory, the display
card type, or even the version of the Microsoft? Direct3D? driver. For more
information, see Width vs. Pitch.
  b.. Make certain you copy to unlocked surfaces. Direct3D copy methods will
fail if called on a locked surface.
  c.. Limit your application's activity while a surface is locked.
  d.. Always copy data aligned to display memory. Microsoft? Windows? 95 and
Windows 98 use a page fault handler, Vflatd.386, to implement a virtual
flat-frame buffer for display cards with bank-switched memory. The handler
allows these display devices to present a linear frame buffer to Direct3D.
Copying data unaligned to display memory can cause the system to suspend
operations if the copy spans memory banks.
  e.. A surface may not be locked if it belongs to a resource assigned to
the D3DPOOL_DEFAULT memory pool unless it is a dynamic texture or a private
(FOURCC) driver format. Back buffer surfaces, which may be accessed using
the Direct3DDevice8.GetBackBuffer and Direct3DSwapChain8.GetBackBuffer
methods, may be locked only if the swap chain was created with the Flags
member of the D3DPRESENT_PARAMETERS type set to include
D3DPRESENTFLAG_LOCKABLE_BACKBUFFER.

--
Phil Taylor
PM : DirectX SDK, Managed DirectX, WindowsXP Inbox 3D Screensavers, and a
few more bits and bobs
http://msdn.microsoft.com/directx
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> Can someone explain to me the methods used to copy an image buffer
> containing YUY2 (YUYV) data to a DirectX 8 Surface. After DX7.1 I haven't
> seen any way of getting direct access to the video memory of a surface.
Then
> again, they did away with my simple old DirectDraw routines. :-(

> A VB6 example would be most helpful.

> Thanks
> Vincent DeCampo



Sun, 03 Oct 2004 09:36:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Store raw image in Access??

2. How to Display Raw Grayscale Image

3. Viewer for binary images (raw format)

4. Code to convert images to *.RAW format

5. Viewing RAW images in VB ??

6. Image push into an Oracle LONG RAW field

7. Viewer for binary images (raw format)

8. Append raw data to Access table

9. Printing Raw Data - Please help

10. Trncating Data to update in Raw Field in oracle from VB.net

11. Spooling raw printer data

12. Problem with long raw data

 

 
Powered by phpBB® Forum Software