summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/TextureRender.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/TextureRender.cc b/src/TextureRender.cc
index 2ce5c03..bae80bc 100644
--- a/src/TextureRender.cc
+++ b/src/TextureRender.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: TextureRender.cc,v 1.4 2002/12/01 19:41:40 fluxgen Exp $ 25// $Id: TextureRender.cc,v 1.5 2002/12/02 20:15:22 fluxgen Exp $
26 26
27#include "TextureRender.hh" 27#include "TextureRender.hh"
28 28
@@ -31,6 +31,8 @@
31#include "App.hh" 31#include "App.hh"
32 32
33#include <iostream> 33#include <iostream>
34#include <string>
35#include <cstdio>
34using namespace std; 36using namespace std;
35 37
36TextureRender::TextureRender(BImageControl &imgctrl, 38TextureRender::TextureRender(BImageControl &imgctrl,
@@ -44,9 +46,27 @@ TextureRender::TextureRender(BImageControl &imgctrl,
44 width = ((signed) w > 0) ? w : 1; 46 width = ((signed) w > 0) ? w : 1;
45 height = ((signed) h > 0) ? h : 1; 47 height = ((signed) h > 0) ? h : 1;
46 48
47 red = new unsigned char[width * height]; 49 red = new (nothrow) unsigned char[width * height];
48 green = new unsigned char[width * height]; 50 if (red == 0) {
49 blue = new unsigned char[width * height]; 51 char sbuf[128];
52 sprintf(sbuf, "%d", width*height);
53 throw string("TextureRender::TextureRender(): Out of memory while allocating red buffer."+ string(sbuf));
54 }
55
56
57 green = new (nothrow) unsigned char[width * height];
58 if (green == 0) {
59 char sbuf[128];
60 sprintf(sbuf, "%d", width*height);
61 throw string("TextureRender::TextureRender(): Out of memory while allocating green buffer. size " + string(sbuf));
62 }
63
64 blue = new (nothrow) unsigned char[width * height];
65 if (blue == 0) {
66 char sbuf[128];
67 sprintf(sbuf, "%d", width*height);
68 throw string("TextureRender::TextureRender(): Out of memory while allocating blue buffer. size " + string(sbuf));
69 }
50 70
51 cpc = imgctrl.colorsPerChannel(); 71 cpc = imgctrl.colorsPerChannel();
52 cpccpc = cpc * cpc; 72 cpccpc = cpc * cpc;