File: GFile_JPEG.h

package info (click to toggle)
kdc2tiff 0.35-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 500 kB
  • ctags: 679
  • sloc: cpp: 3,107; ansic: 832; sh: 330; makefile: 49
file content (81 lines) | stat: -rw-r--r-- 1,804 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef _GFile_JPEG_H
#define _GFile_JPEG_H

#include "GFile.h"

/* GFile (ie. GImage) decendent for reading JPEG files.
 * 
 * Written by:  Chris Studholme
 * Last Update: 8-January-2000
 * Copyright:   GPL (http://www.fsf.org/copyleft/gpl.html)
 */

class GFile_JPEG : public GFile {
 protected:
  int w,h;
  unsigned int histogram[256];

 public:
  GFile_JPEG(const char* filename, bool fast=false);
  ~GFile_JPEG();

  static bool supportsFile(FILE* file);

  bool isOK() {
    return ((red!=NULL)&&(green!=NULL)&&(blue!=NULL));
  }

  void FindBestMinMax(int& min, int& max) {
    calculateBestMinMax(min,max,histogram);
  }

  const char* getComments() {
    return NULL;
  }
  int getWidth() {
    return w;
  }
  int getHeight() {
    return h;
  }
  
  /* width/height of individual pixel */
  double getAspectRatio() {
    return 1;
  }
  
  /* must have x1<x2, y1<y2,
   * pixel values are typically in [-16384,16383], but may be
   * out of this range
   */
  void getPixel(short& r, short& g, short& b,
		float x1, float y1, float x2, float y2) {
    r = red->getPixel(x1,y1,x2,y2);
    g = green->getPixel(x1,y1,x2,y2);
    b = blue->getPixel(x1,y1,x2,y2);
  }

  /* must have y1<y2
   */
  void getScanLineHorz(short* r, short* g, short* b,
		       float x1, float y1,
		       float x2, float y2, int npixels) {
    red->getScanLineHorz(r,x1,y1,x2,y2,npixels);
    green->getScanLineHorz(g,x1,y1,x2,y2,npixels);
    blue->getScanLineHorz(b,x1,y1,x2,y2,npixels);
  }

  /* must have x1<x2
   */
  void getScanLineVert(short* r, short* g, short* b,
		       float x1, float y1,
		       float x2, float y2, int npixels) {
    red->getScanLineVert(r,x1,y1,x2,y2,npixels);
    green->getScanLineVert(g,x1,y1,x2,y2,npixels);
    blue->getScanLineVert(b,x1,y1,x2,y2,npixels);
  }

};

#endif