⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcraw_common.h

📁 JPEG2000实现的源码
💻 H
字号:
/*****************************************************************************/
/* Copyright 2000, Eastman Kodak Company                                     */
/* All rights reserved                                                       */
/* File: "mcraw_common.h"                                                    */
/* Description: Public prototypes and definitions for reading and writing    */
/*              values from a multi-component raw image                      */
/* Author: Austin Lan                                                        */
/* Affiliation: Eastman Kodak Company                                        */
/* Version: VM9.0                                                            */
/* Last Revised: 18 April, 2001                                              */
/*****************************************************************************/
#ifndef MCRAW_COMMON_H
#define MCRAW_COMMON_H

/*****************************************************************************
  This collection of routines can be used to read a "slice" or "page" of data
  from a multi-component raw image.  The #define set below refer to the 
  organization and interleave of the image.  "L", "P", and "B" are 
  abbreviations for "line", "pixel", and "band".  If the image has a fixed
  length header, then the `skip_bytes' argument can be used to skip the header.
  Valid `file_byte_depth' values are 1, 2, 4.  For the read functions,
  the `buf' array is expect to have enough memory allocated to it to hold the
  full page of data.

  A character string is returned if an error is encountered; otherwise, a NULL 
  is returned if OK.

  File organization has the following meanings, in terms of data storage:
  BSQ:
           B0 -> L0 -> P0 P1 P2 P3 ...
	             L1 -> P0 P1 P2 P3 ...
		      .
		      .
			  .
	       B1 -> L0 -> P0 P1 P2 P3 ...
	             L1 -> P0 P1 P2 P3 ...
		      .
		      .
			  .
  Therefore, the first data to appear in the file corresponds to the first
  band.  For the first band, the first data to appear corresponds to all
  the pixels for the first line.

  BIL:
           L0 -> B0 -> P0 P1 P2 P3 ...
	             B1 -> P0 P1 P2 P3 ...
		      .
		      .
			  .
	       L1 -> B0 -> P0 P1 P2 P3 ...
	             B1 -> P0 P1 P2 P3 ...
		      .
		      .
			  .
  Therefore, the first data to appear in the file corresponds to the first
  line.  For the first line, the first data to appear corresponds to all
  the pixels for the first band.

  BIP:
           L0 -> P0 -> B0 B1 B2 B3 ...
	             P1 -> B0 B1 B2 B3 ...
		      .
		      .
			  .
	       L1 -> P0 -> B0 B1 B2 B3 ...
	             P1 -> B0 B1 B2 B3 ...
		      .
		      .
			  .
  Therefore, the first data to appear in the file corresponds to the first
  line.  For the first line, the first data to appear corresponds to all
  the bands for the first pixel.

  *************
  Example Usage
  *************

   FILE *in_fp, *out_fp;
   char *status;

   ** Open a file for read and write **

   if ((in_fp = fopen(in_fname, "rb")) == NULL) {
      print error;
   }
   if ((out_fp = fopen(out_fname, "wb")) == NULL) {
      print error;
   }

   ** Reading in a BxP (BIL) page of data from a BSQ organized file.  Note that
      this operation is better suited for a BIL organized file, but it 
      will work for any of the three possible organizations. **

   if (status = readBxP(in_page, rows, cols, bands, in_file_byte_depth, BSQ,
            skip_bytes, which_line, in_fp)) {
      print error;
   }

   ** Writing out a BxP (BIL) page of data to a BIP organized file. No
      beginning bytes are skipped. **

   if (status = writeBxP(out_page, rows, cols, bands, out_file_byte_depth,
             BIP, 0, which_line, out_fp)) {
      print "status" string with error message;
   }

   ** Close files **

   fclose(in_fp);
   fclose(out_fp);
 *****************************************************************************/

#define BSQ 0 /* Band-sequential */
#define BIL 1 /* Band-interleaved-by-line */
#define BIP 2 /* Band-interleaved-by-pixel (aka. pixel-interleaved) */

char *readBxP(void **buf, int rows, int cols, int bands, int file_byte_depth,
	      int data_org, int skip_bytes, int which_line, FILE *fp);
char *writeBxP(void **buf, int rows, int cols, int bands, int file_byte_depth,
	       int data_org, int skip_bytes, int which_line, FILE *fp);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -