home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / guicast / bcbitmap.h < prev    next >
C/C++ Source or Header  |  2000-11-29  |  4KB  |  138 lines

  1. #ifndef BCBITMAP_H
  2. #define BCBITMAP_H
  3.  
  4. #include <X11/Xlib.h>
  5. #include <sys/ipc.h>
  6. #include <sys/shm.h>
  7. #include <X11/extensions/XShm.h>
  8. #include <X11/extensions/Xvlib.h>
  9.  
  10. #include "bcwindowbase.inc"
  11. #include "colors.h"
  12. #include "sizes.h"
  13. #include "vframe.inc"
  14.  
  15. #define BITMAP_RING 4
  16.  
  17. class BC_Bitmap
  18. {
  19. public:
  20.     BC_Bitmap(BC_WindowBase *parent_window, unsigned char *png_data);
  21.     BC_Bitmap(BC_WindowBase *parent_window, VFrame *frame);
  22.     BC_Bitmap(BC_WindowBase *parent_window, int w, int h, int color_model, int use_shm = 1);
  23.     virtual ~BC_Bitmap();
  24.  
  25. // transfer VFrame
  26.     int read_frame(VFrame *frame, int use_alpha,
  27.         int in_x, int in_y, int in_w, int in_h,
  28.         int out_x, int out_y, int out_w, int out_h);
  29. // x1, y1, x2, y2 dimensions of output area
  30.     int read_frame(VFrame *frame, int x1, int y1, int x2, int y2, int use_alpha);
  31. // Reset bitmap to match the new parameters
  32.     int match_params(int w, int h, int color_model, int use_shm);
  33. // Test if bitmap already matches parameters
  34.     int params_match(int w, int h, int color_model, int use_shm);
  35.  
  36. // If dont_wait is true, the XSync comes before the flash.
  37. // For YUV bitmaps, the image is scaled to fill dest_x ... w * dest_y ... h
  38.     int write_drawable(Drawable &pixmap, 
  39.             GC &gc,
  40.             int source_x, 
  41.             int source_y, 
  42.             int source_w,
  43.             int source_h,
  44.             int dest_x, 
  45.             int dest_y, 
  46.             int dest_w, 
  47.             int dest_h, 
  48.             int dont_wait);
  49.     int write_drawable(Drawable &pixmap, 
  50.             GC &gc,
  51.             int dest_x, 
  52.             int dest_y, 
  53.             int source_x, 
  54.             int source_y, 
  55.             int dest_w, 
  56.             int dest_h, 
  57.             int dont_wait);
  58. // the bitmap must be wholly contained in the source during a GetImage
  59.     int read_drawable(Drawable &pixmap, int source_x, int source_y);
  60.  
  61.     int rotate_90(int side);
  62.     int get_w();
  63.     int get_h();
  64. // Get data pointers for current ring buffer
  65.     unsigned char* get_data();
  66.     unsigned char* get_y_plane();
  67.     unsigned char* get_u_plane();
  68.     unsigned char* get_v_plane();
  69. // Get the frame buffer itself
  70.     int get_color_model();
  71.     int hardware_scaling();
  72.     unsigned char** get_row_pointers();
  73.     long get_shm_id();
  74.     long get_shm_size();
  75. // Offset of current ringbuffer in shared memory
  76.     long get_shm_offset();
  77. // Returns plane offset + ringbuffer offset
  78.     long get_y_shm_offset();
  79.     long get_u_shm_offset();
  80.     long get_v_shm_offset();
  81. // Returns just the plane offset
  82.     long get_y_offset();
  83.     long get_u_offset();
  84.     long get_v_offset();
  85.     
  86. // Rewing ringbuffer to the previous frame
  87.     void rewind_ringbuffer();
  88.     int set_bg_color(int color);
  89.     int invert();
  90.  
  91. private:
  92.     int initialize(BC_WindowBase *parent_window, int w, int h, int color_model, int use_shm);
  93.     int allocate_data();
  94.     int delete_data();
  95.     int get_default_depth();
  96.  
  97.     int ring_buffers, current_ringbuffer;
  98.     int w, h;
  99. // Color model from colormodels.h
  100.     int color_model;
  101. // Background color for using pngs
  102.     int bg_color;
  103. // Override top_level for small bitmaps
  104.     int use_shm;
  105.     BC_WindowBase *top_level;
  106.     BC_WindowBase *parent_window;
  107. // Points directly to the frame buffer
  108.     unsigned char *data[BITMAP_RING];   
  109. // Row pointers to the frame buffer
  110.     unsigned char **row_data[BITMAP_RING];   
  111.     int xv_portid;
  112. // This differs from the depth parameter of top_level
  113.     int bits_per_pixel;
  114. // From the ximage
  115.     long bytes_per_line;
  116. // For resetting XVideo
  117.     int last_pixmap_used;
  118. // Background color
  119.     unsigned char bg_r, bg_g, bg_b;
  120. // For less than 8 bit depths
  121.     int bit_counter;
  122.  
  123. // X11 objects
  124. // Need last pixmap to stop XVideo
  125.     Drawable last_pixmap;
  126.     XImage *ximage[BITMAP_RING];
  127.     XvImage *xv_image[BITMAP_RING];
  128.     XShmSegmentInfo shm_info;
  129. };
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. #endif
  138.