~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/util/render/dither/ditherRGB_flipped.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  flips RGB images
 
3
  Copyright (C) 2000  Martin Vogt
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU Library General Public License as published by
 
7
  the Free Software Foundation.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#include "ditherRGB_flipped.h"
 
15
 
 
16
 
 
17
 
 
18
DitherRGB_flipped::DitherRGB_flipped() {
 
19
  flipSpace=NULL;
 
20
  flipSize=0;
 
21
}
 
22
 
 
23
DitherRGB_flipped::~DitherRGB_flipped() {
 
24
  if (flipSpace != NULL) {
 
25
    delete flipSpace;
 
26
  }
 
27
}
 
28
 
 
29
 
 
30
 
 
31
 
 
32
void DitherRGB_flipped::flipRGBImage(unsigned char* dest,unsigned char* src,
 
33
                                     int depth,int width,int height,int ) {
 
34
 
 
35
  int byteDepth;
 
36
 
 
37
  switch(depth) {
 
38
  case 8:
 
39
    byteDepth=1;
 
40
    break;
 
41
  case 15:
 
42
  case 16:
 
43
    byteDepth=2;
 
44
    break;
 
45
  case 24:
 
46
  case 32:
 
47
    byteDepth=4;
 
48
    break;
 
49
  default:
 
50
    cout << "unknown byteDepth:"<<depth
 
51
         << " in DitherRGB_flipped::flipRGBImage"<<endl;
 
52
    return;
 
53
  }
 
54
    
 
55
 
 
56
  int spaceNeeded=width*height*byteDepth;
 
57
 
 
58
  if (spaceNeeded > flipSize) {
 
59
    if (flipSpace != NULL) {
 
60
      delete flipSpace;
 
61
    }
 
62
    cout << "flipSpace:"<<spaceNeeded<<endl;
 
63
    flipSpace=new unsigned char[spaceNeeded+64];
 
64
    flipSize=spaceNeeded;
 
65
  }
 
66
 
 
67
  int i;
 
68
  int lineSize=width*byteDepth;
 
69
  unsigned char* end=dest+lineSize*(height-1);
 
70
 
 
71
  for (i=0;i<height;i++) {
 
72
    memcpy(end,src,lineSize);
 
73
    src+=lineSize;
 
74
    end-=lineSize;
 
75
  }
 
76
 
 
77
}
 
78
 
 
79