aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp210
1 files changed, 105 insertions, 105 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp
index 3bc1737..6bcba91 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CImageWriterPPM.cpp
@@ -1,105 +1,105 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "CImageWriterPPM.h" 5#include "CImageWriterPPM.h"
6 6
7#ifdef _IRR_COMPILE_WITH_PPM_WRITER_ 7#ifdef _IRR_COMPILE_WITH_PPM_WRITER_
8 8
9#include "IWriteFile.h" 9#include "IWriteFile.h"
10#include "IImage.h" 10#include "IImage.h"
11#include "dimension2d.h" 11#include "dimension2d.h"
12#include "irrString.h" 12#include "irrString.h"
13 13
14namespace irr 14namespace irr
15{ 15{
16namespace video 16namespace video
17{ 17{
18 18
19 19
20IImageWriter* createImageWriterPPM() 20IImageWriter* createImageWriterPPM()
21{ 21{
22 return new CImageWriterPPM; 22 return new CImageWriterPPM;
23} 23}
24 24
25 25
26CImageWriterPPM::CImageWriterPPM() 26CImageWriterPPM::CImageWriterPPM()
27{ 27{
28#ifdef _DEBUG 28#ifdef _DEBUG
29 setDebugName("CImageWriterPPM"); 29 setDebugName("CImageWriterPPM");
30#endif 30#endif
31} 31}
32 32
33 33
34bool CImageWriterPPM::isAWriteableFileExtension(const io::path& filename) const 34bool CImageWriterPPM::isAWriteableFileExtension(const io::path& filename) const
35{ 35{
36 return core::hasFileExtension ( filename, "ppm" ); 36 return core::hasFileExtension ( filename, "ppm" );
37} 37}
38 38
39 39
40bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image, u32 param) const 40bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image, u32 param) const
41{ 41{
42 char cache[70]; 42 char cache[70];
43 int size; 43 int size;
44 44
45 const core::dimension2d<u32>& imageSize = image->getDimension(); 45 const core::dimension2d<u32>& imageSize = image->getDimension();
46 46
47 const bool binary = false; 47 const bool binary = false;
48 48
49 if (binary) 49 if (binary)
50 size = snprintf(cache, 70, "P6\n"); 50 size = snprintf(cache, 70, "P6\n");
51 else 51 else
52 size = snprintf(cache, 70, "P3\n"); 52 size = snprintf(cache, 70, "P3\n");
53 53
54 if (file->write(cache, size) != size) 54 if (file->write(cache, size) != size)
55 return false; 55 return false;
56 56
57 size = snprintf(cache, 70, "%d %d\n", imageSize.Width, imageSize.Height); 57 size = snprintf(cache, 70, "%d %d\n", imageSize.Width, imageSize.Height);
58 if (file->write(cache, size) != size) 58 if (file->write(cache, size) != size)
59 return false; 59 return false;
60 60
61 size = snprintf(cache, 70, "255\n"); 61 size = snprintf(cache, 70, "255\n");
62 if (file->write(cache, size) != size) 62 if (file->write(cache, size) != size)
63 return false; 63 return false;
64 64
65 if (binary) 65 if (binary)
66 { 66 {
67 for (u32 h = 0; h < imageSize.Height; ++h) 67 for (u32 h = 0; h < imageSize.Height; ++h)
68 { 68 {
69 for (u32 c = 0; c < imageSize.Width; ++c) 69 for (u32 c = 0; c < imageSize.Width; ++c)
70 { 70 {
71 const video::SColor& pixel = image->getPixel(c, h); 71 const video::SColor& pixel = image->getPixel(c, h);
72 const u8 r = (u8)(pixel.getRed() & 0xff); 72 const u8 r = (u8)(pixel.getRed() & 0xff);
73 const u8 g = (u8)(pixel.getGreen() & 0xff); 73 const u8 g = (u8)(pixel.getGreen() & 0xff);
74 const u8 b = (u8)(pixel.getBlue() & 0xff); 74 const u8 b = (u8)(pixel.getBlue() & 0xff);
75 file->write(&r, 1); 75 file->write(&r, 1);
76 file->write(&g, 1); 76 file->write(&g, 1);
77 file->write(&b, 1); 77 file->write(&b, 1);
78 } 78 }
79 } 79 }
80 } 80 }
81 else 81 else
82 { 82 {
83 s32 n = 0; 83 s32 n = 0;
84 84
85 for (u32 h = 0; h < imageSize.Height; ++h) 85 for (u32 h = 0; h < imageSize.Height; ++h)
86 { 86 {
87 for (u32 c = 0; c < imageSize.Width; ++c, ++n) 87 for (u32 c = 0; c < imageSize.Width; ++c, ++n)
88 { 88 {
89 const video::SColor& pixel = image->getPixel(c, h); 89 const video::SColor& pixel = image->getPixel(c, h);
90 size = snprintf(cache, 70, "%.3u %.3u %.3u%s", pixel.getRed(), pixel.getGreen(), pixel.getBlue(), n % 5 == 4 ? "\n" : " "); 90 size = snprintf(cache, 70, "%.3u %.3u %.3u%s", pixel.getRed(), pixel.getGreen(), pixel.getBlue(), n % 5 == 4 ? "\n" : " ");
91 if (file->write(cache, size) != size) 91 if (file->write(cache, size) != size)
92 return false; 92 return false;
93 } 93 }
94 } 94 }
95 } 95 }
96 96
97 return true; 97 return true;
98} 98}
99 99
100 100
101} // namespace video 101} // namespace video
102} // namespace irr 102} // namespace irr
103 103
104#endif 104#endif
105 105