NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Image.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "gui/Image.hpp"
29 #include "gpu/CudaModule.hpp"
30 #include "io/File.hpp"
31 #include "io/ImageBinaryIO.hpp"
32 #include "io/ImageLodePngIO.hpp"
33 #include "io/ImageRawPngIO.hpp"
34 #include "io/ImageTargaIO.hpp"
35 #include "io/ImageTiffIO.hpp"
36 #include "io/ImageBmpIO.hpp"
37 
38 using namespace FW;
39 
40 //------------------------------------------------------------------------
41 
42 #define C8(TYPE, OFS) { ChannelType_ ## TYPE, ChannelFormat_Clamp, OFS, 1, 0, 8 }
43 #define C16(TYPE, OFS, SIZE) { ChannelType_ ## TYPE, ChannelFormat_Clamp, 0, 2, OFS, SIZE }
44 #define C32(TYPE, OFS) { ChannelType_ ## TYPE, ChannelFormat_Clamp, 0, 4, OFS, 8 }
45 #define CF32(TYPE, OFS) { ChannelType_ ## TYPE, ChannelFormat_Float, OFS, 4, 0, 32 }
46 
47 const ImageFormat::StaticFormat ImageFormat::s_staticFormats[] =
48 {
49  /* R8_G8_B8 */ { 3, 3, { C8(R,0), C8(G,1), C8(B,2) }, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, false },
50  /* R8_G8_B8_A8 */ { 4, 4, { C8(R,0), C8(G,1), C8(B,2), C8(A,3) }, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false },
51  /* A8 */ { 1, 1, { C8(A,0) }, GL_ALPHA8, GL_ALPHA, GL_UNSIGNED_BYTE, false },
52  /* XBGR_8888 */ { 4, 3, { C32(R,0), C32(G,8), C32(B,16) }, GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, true },
53  /* ABGR_8888 */ { 4, 4, { C32(R,0), C32(G,8), C32(B,16), C32(A,24) }, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, true },
54 
55  /* RGB_565 */ { 2, 3, { C16(R,11,5), C16(G,5,6), C16(B,0,5) }, GL_RGB5, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, false },
56  /* RGBA_5551 */ { 2, 4, { C16(R,11,5), C16(G,6,5), C16(B,1,5), C16(A,0,1) }, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, false },
57 
58  /* RGB_Vec3f */ { 12, 3, { CF32(R,0), CF32(G,4), CF32(B,8) }, GL_RGB32F, GL_RGB, GL_FLOAT, false },
59  /* RGBA_Vec4f */ { 16, 4, { CF32(R,0), CF32(G,4), CF32(B,8), CF32(A,12) }, GL_RGBA32F, GL_RGBA, GL_FLOAT, false },
60  /* A_F32 */ { 4, 1, { CF32(A,0) }, GL_ALPHA32F_ARB, GL_ALPHA, GL_FLOAT, false },
61 };
62 
63 #undef C8
64 #undef C16
65 #undef C32
66 #undef CF32
67 
68 //------------------------------------------------------------------------
69 
70 #define RGB_565_TO_ABGR_8888(V) ((V >> 8) & 0x000000F8) | (V >> 13) | ((V << 5) & 0x0000FC00) | ((V >> 1) & 0x00000300) | ((V << 19) & 0x00F80000) | ((V >> 14) & 0x00070000) | 0xFF000000
71 #define ABGR_8888_TO_RGB_565(V) (U16)(((V << 8) & 0xF800) | ((V >> 5) & 0x07E0) | ((V >> 19) & 0x001F))
72 
73 #define RGBA_5551_TO_ABGR_8888(V) ((V >> 8) & 0x000000F8) | (V >> 13) | ((V << 5) & 0x0000F800) | (V & 0x00000700) | ((V << 18) & 0x00F80000) | ((V >> 13) & 0x00070000) | ((S32)(V << 31) >> 7)
74 #define ABGR_8888_TO_RGBA_5551(V) (U16)(((V << 8) & 0xF800) | ((V >> 5) & 0x07C0) | ((V >> 18) & 0x003E) | (V >> 31))
75 
76 //------------------------------------------------------------------------
77 
79 {
80  if (m_id != ID_Max)
81  return m_id;
82 
83  FW_ASSERT(FW_ARRAY_SIZE(s_staticFormats) == ID_Generic);
84  for (int i = 0; i < (int)ID_Generic; i++)
85  {
86  const StaticFormat& f = s_staticFormats[i];
87  if (m_genericBPP == f.bpp &&
88  m_genericChannels.getSize() == f.numChannels &&
89  memcmp(m_genericChannels.getPtr(), f.channels, m_genericChannels.getNumBytes()) == 0)
90  {
91  m_id = (ID)i;
92  return m_id;
93  }
94  }
95 
96  m_id = ID_Generic;
97  return m_id;
98 }
99 
100 //------------------------------------------------------------------------
101 
103 {
104  ID id = getID();
105  FW_ASSERT(FW_ARRAY_SIZE(s_staticFormats) == ID_Generic);
106  return (id < ID_Generic) ? &s_staticFormats[id] : NULL;
107 }
108 
109 //------------------------------------------------------------------------
110 
111 int ImageFormat::getBPP(void) const
112 {
113  FW_ASSERT(FW_ARRAY_SIZE(s_staticFormats) == ID_Generic);
114  return (m_id < ID_Generic) ? s_staticFormats[m_id].bpp : m_genericBPP;
115 }
116 
117 //------------------------------------------------------------------------
118 
120 {
121  FW_ASSERT(FW_ARRAY_SIZE(s_staticFormats) == ID_Generic);
122  return (m_id < ID_Generic) ? s_staticFormats[m_id].numChannels : m_genericChannels.getSize();
123 }
124 
125 //------------------------------------------------------------------------
126 
128 {
129  FW_ASSERT(idx >= 0 && idx < getNumChannels());
130  FW_ASSERT(FW_ARRAY_SIZE(s_staticFormats) == ID_Generic);
131  return (m_id < ID_Generic) ? s_staticFormats[m_id].channels[idx] : m_genericChannels[idx];
132 }
133 
134 //------------------------------------------------------------------------
135 
137 {
138  int num = getNumChannels();
139  for (int i = 0; i < num; i++)
140  if (getChannel(i).type == type)
141  return i;
142  return -1;
143 }
144 
145 //------------------------------------------------------------------------
146 
147 void ImageFormat::set(const ImageFormat& other)
148 {
149  m_id = other.m_id;
150  if (m_id >= ID_Generic)
151  {
152  m_genericBPP = other.m_genericBPP;
153  m_genericChannels = other.m_genericChannels;
154  }
155 }
156 
157 //------------------------------------------------------------------------
158 
160 {
161  m_id = ID_Generic;
162  m_genericBPP = 0;
163  m_genericChannels.clear();
164 }
165 
166 //------------------------------------------------------------------------
167 
168 void ImageFormat::addChannel(const Channel& channel)
169 {
170  if (m_id < ID_Generic)
171  {
172  const StaticFormat& f = s_staticFormats[m_id];
173  m_genericBPP = f.bpp;
174  m_genericChannels.set(f.channels, f.numChannels);
175  }
176 
177  m_id = ID_Max;
178  m_genericBPP = max(m_genericBPP, channel.wordOfs + channel.wordSize);
179  m_genericChannels.add(channel);
180 }
181 
182 //------------------------------------------------------------------------
183 
185 {
187 
188  // Requires little endian machine => check.
189 
190  if (sf && sf->glLittleEndian)
191  {
192  U32 tmp = 0x12345678;
193  if (*(U8*)&tmp != 0x78)
194  sf = NULL;
195  }
196 
197  // Maps directly to a GL format => done.
198 
199  if (sf && sf->glInternalFormat != GL_NONE)
200  return getID();
201 
202  // Otherwise => select the closest match.
203 
204  U32 channels = 0;
205  bool isFloat = false;
206  for (int i = 0; i < getNumChannels(); i++)
207  {
208  const ImageFormat::Channel& c = getChannel(i);
210  continue;
211 
212  channels |= 1 < c.type;
214  isFloat = true;
215  }
216 
217  if ((channels & 7) == 0)
218  return (isFloat) ? ImageFormat::A_F32 : ImageFormat::A8;
219  if ((channels & 8) == 0)
220  return (isFloat) ? ImageFormat::RGB_Vec3f : ImageFormat::R8_G8_B8;
222 }
223 
224 //------------------------------------------------------------------------
225 
226 bool ImageFormat::operator==(const ImageFormat& other) const
227 {
228  if (m_id < ID_Generic || other.m_id < ID_Generic)
229  return (getID() == other.getID());
230 
231  return (
232  m_genericBPP == other.m_genericBPP &&
233  m_genericChannels.getSize() == other.m_genericChannels.getSize() &&
234  memcmp(m_genericChannels.getPtr(), other.m_genericChannels.getPtr(), m_genericChannels.getNumBytes()) == 0);
235 }
236 
237 //------------------------------------------------------------------------
238 
240 {
241  init(size, format);
242  FW_ASSERT(size.min() == 0 || ptr);
243 
244  S64 lo = 0;
245  S64 hi = 0;
246  if (size.min() != 0)
247  {
248  lo = min(stride * (size.y - 1), (S64)0);
249  hi = max(stride * (size.y - 1), (S64)0) + size.x * format.getBPP();
250  }
251 
252  m_stride = stride;
253  m_buffer = new Buffer((U8*)ptr + lo, hi - lo);
254  m_ownBuffer = true;
255  m_offset = -lo;
256 }
257 
258 //------------------------------------------------------------------------
259 
261 {
262  init(size, format);
263  FW_ASSERT(size.min() == 0 || ofs + min(stride * (size.y - 1), (S64)0) >= 0);
264  FW_ASSERT(size.min() == 0 || ofs + max(stride * (size.y - 1), (S64)0) + size.x * format.getBPP() <= buffer.getSize());
265 
266  m_stride = stride;
267  m_buffer = &buffer;
268  m_ownBuffer = false;
269  m_offset = ofs;
270 }
271 
272 //------------------------------------------------------------------------
273 
275 {
276  if (m_ownBuffer)
277  delete m_buffer;
278 }
279 
280 //------------------------------------------------------------------------
281 
282 U32 Image::getABGR(const Vec2i& pos) const
283 {
284  FW_ASSERT(contains(pos, 1));
285  const U8* p = getPtr(pos);
286 
287  switch (m_format.getID())
288  {
289  case ImageFormat::R8_G8_B8: return p[0] | (p[1] << 8) | (p[2] << 16) | 0xFF000000;
290  case ImageFormat::R8_G8_B8_A8: return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
291  case ImageFormat::A8: return *p << 24;
292  case ImageFormat::XBGR_8888: return *(const U32*)p | 0xFF000000;
293  case ImageFormat::ABGR_8888: return *(const U32*)p;
294 
295  case ImageFormat::RGB_565: { U16 v = *(const U16*)p; return RGB_565_TO_ABGR_8888(v); }
296  case ImageFormat::RGBA_5551: { U16 v = *(const U16*)p; return RGBA_5551_TO_ABGR_8888(v); }
297 
298  case ImageFormat::RGB_Vec3f: return Vec4f(*(const Vec3f*)p, 1.0f).toABGR();
299  case ImageFormat::RGBA_Vec4f: return ((const Vec4f*)p)->toABGR();
300  case ImageFormat::A_F32: return clamp((int)(*(const F32*)p * 255.0f + 0.5f), 0x00, 0xFF) << 24;
301 
302  default:
303  {
304  getChannels(pos);
305  bool hasAlpha = false;
306  U32 value = 0;
307 
308  for (int i = 0; i < m_channelTmp.getSize(); i++)
309  {
310  U32 v = clamp((int)(m_channelTmp[i] * 255.0f + 0.5f), 0x00, 0xFF);
311  switch (m_format.getChannel(i).type)
312  {
313  case ImageFormat::ChannelType_R: value |= v; break;
314  case ImageFormat::ChannelType_G: value |= v << 8; break;
315  case ImageFormat::ChannelType_B: value |= v << 16; break;
316  case ImageFormat::ChannelType_A: value |= v << 24; hasAlpha = true; break;
317  }
318  }
319 
320  if (!hasAlpha)
321  value |= 0xFF000000;
322  return value;
323  }
324  }
325 }
326 
327 //------------------------------------------------------------------------
328 
329 void Image::setABGR(const Vec2i& pos, U32 value)
330 {
331  FW_ASSERT(contains(pos, 1));
332  U8* p = getMutablePtr(pos);
333 
334  switch (m_format.getID())
335  {
336  case ImageFormat::R8_G8_B8: p[0] = (U8)value; p[1] = (U8)(value >> 8); p[2] = (U8)(value >> 16); break;
337  case ImageFormat::R8_G8_B8_A8: p[0] = (U8)value; p[1] = (U8)(value >> 8); p[2] = (U8)(value >> 16); p[3] = (U8)(value >> 24); break;
338  case ImageFormat::A8: *p = (U8)(value >> 24); break;
339  case ImageFormat::XBGR_8888: *(U32*)p = value; break;
340  case ImageFormat::ABGR_8888: *(U32*)p = value; break;
341 
342  case ImageFormat::RGB_565: *(U16*)p = ABGR_8888_TO_RGB_565(value); break;
343  case ImageFormat::RGBA_5551: *(U16*)p = ABGR_8888_TO_RGBA_5551(value); break;
344 
345  case ImageFormat::RGB_Vec3f: *(Vec3f*)p = Vec4f::fromABGR(value).getXYZ(); break;
346  case ImageFormat::RGBA_Vec4f: *(Vec4f*)p = Vec4f::fromABGR(value); break;
347  case ImageFormat::A_F32: *(F32*)p = (F32)(value >> 24) / 255.0f; break;
348 
349  default:
350  for (int i = 0; i < m_channelTmp.getSize(); i++)
351  {
352  F32& channel = m_channelTmp[i];
353  switch (m_format.getChannel(i).type)
354  {
355  case ImageFormat::ChannelType_R: channel = (F32)(value & 0xFF) / 255.0f; break;
356  case ImageFormat::ChannelType_G: channel = (F32)((value >> 8) & 0xFF) / 255.0f; break;
357  case ImageFormat::ChannelType_B: channel = (F32)((value >> 16) & 0xFF) / 255.0f; break;
358  case ImageFormat::ChannelType_A: channel = (F32)(value >> 24) / 255.0f; break;
359  default: channel = 0.0f; break;
360  }
361  }
362  setChannels(pos, m_channelTmp.getPtr());
363  break;
364  }
365 }
366 
367 //------------------------------------------------------------------------
368 
369 Vec4f Image::getVec4f(const Vec2i& pos) const
370 {
371  FW_ASSERT(contains(pos, 1));
372  const U8* p = getPtr(pos);
373 
374  switch (m_format.getID())
375  {
376  case ImageFormat::A8: return Vec4f(0.0f, 0.0f, 0.0f, (F32)(*p / 255.0f));
377  case ImageFormat::XBGR_8888: return Vec4f::fromABGR(*(const U32*)p | 0xFF000000);
378  case ImageFormat::ABGR_8888: return Vec4f::fromABGR(*(const U32*)p);
379  case ImageFormat::RGB_Vec3f: return Vec4f(*(const Vec3f*)p, 1.0f);
380  case ImageFormat::RGBA_Vec4f: return *(const Vec4f*)p;
381  case ImageFormat::A_F32: return Vec4f(0.0f, 0.0f, 0.0f, *(const F32*)p);
382 
387  return Vec4f::fromABGR(getABGR(pos));
388 
389  default:
390  {
391  getChannels(pos);
392  Vec4f value(0.0f, 0.0f, 0.0f, 1.0f);
393  for (int i = 0; i < m_channelTmp.getSize(); i++)
394  {
395  ImageFormat::ChannelType t = m_format.getChannel(i).type;
397  value[t] = m_channelTmp[i];
398  }
399  return value;
400  }
401  }
402 }
403 
404 //------------------------------------------------------------------------
405 
406 void Image::setVec4f(const Vec2i& pos, const Vec4f& value)
407 {
408  FW_ASSERT(contains(pos, 1));
409  U8* p = getMutablePtr(pos);
410 
411  switch (m_format.getID())
412  {
413  case ImageFormat::A8: *p = (U8)clamp((int)(value.w * 255.0f + 0.5f), 0x00, 0xFF); break;
414  case ImageFormat::XBGR_8888: *(U32*)p = value.toABGR(); break;
415  case ImageFormat::ABGR_8888: *(U32*)p = value.toABGR(); break;
416  case ImageFormat::RGB_Vec3f: *(Vec3f*)p = value.getXYZ(); break;
417  case ImageFormat::RGBA_Vec4f: *(Vec4f*)p = value; break;
418  case ImageFormat::A_F32: *(F32*)p = value.w; break;
419 
424  setABGR(pos, value.toABGR());
425  break;
426 
427  default:
428  for (int i = 0; i < m_channelTmp.getSize(); i++)
429  {
430  ImageFormat::ChannelType t = m_format.getChannel(i).type;
431  m_channelTmp[i] = (t <= ImageFormat::ChannelType_A) ? value[t] : 0.0f;
432  }
433  setChannels(pos, m_channelTmp.getPtr());
434  break;
435  }
436 }
437 
438 //------------------------------------------------------------------------
439 
440 void Image::flipX(void)
441 {
442  int bpp = getBPP();
443  for (int y = 0; y < m_size.y; y++)
444  {
445  U8* ptrA = getMutablePtr(Vec2i(0, y));
446  U8* ptrB = getMutablePtr(Vec2i(m_size.x - 1, y));
447  for (int x = (m_size.x >> 1); x > 0; x--)
448  {
449  for (int i = 0; i < bpp; i++)
450  swap(ptrA[i], ptrB[i]);
451  ptrA += bpp;
452  ptrB -= bpp;
453  }
454  }
455 }
456 
457 //------------------------------------------------------------------------
458 
459 void Image::flipY(void)
460 {
461  int scanBytes = m_size.x * getBPP();
462  Array<U8> tmp(NULL, scanBytes);
463  for (int y = (m_size.y >> 1) - 1; y >= 0; y--)
464  {
465  U8* ptrA = getMutablePtr(Vec2i(0, y));
466  U8* ptrB = getMutablePtr(Vec2i(0, m_size.y - 1 - y));
467  memcpy(tmp.getPtr(), ptrA, scanBytes);
468  memcpy(ptrA, ptrB, scanBytes);
469  memcpy(ptrB, tmp.getPtr(), scanBytes);
470  }
471 }
472 
473 //------------------------------------------------------------------------
474 
475 GLuint Image::createGLTexture(ImageFormat::ID desiredFormat, bool generateMipmaps) const
476 {
477  // Select format.
478 
479  ImageFormat::ID formatID;
480  if (desiredFormat == ImageFormat::ID_Max)
481  formatID = m_format.getGLFormat();
482  else
483  formatID = ImageFormat(desiredFormat).getGLFormat();
484 
485  const ImageFormat::StaticFormat* sf = ImageFormat(formatID).getStaticFormat();
486  FW_ASSERT(sf);
487 
488  // Image data not usable directly => convert.
489 
490  Image* converted = NULL;
491  const Image* img = this;
492  if (m_size.min() == 0 || m_format.getID() != formatID || m_stride != getBPP() * m_size.x)
493  {
494  converted = new Image(max(m_size, 1), formatID);
495  converted->set(*this);
496  img = converted;
497  }
498 
499  // Create texture.
500 
502 
503  GLint oldTex = 0;
504  glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTex);
505 
506  GLuint tex = 0;
507  glGenTextures(1, &tex);
508  glBindTexture(GL_TEXTURE_2D, tex);
509  glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, generateMipmaps);
510  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (generateMipmaps) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
511  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
512 
513  // Uncomment to enable anisotropic filtering:
514 // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, FW_S32_MAX);
515 
516  glTexImage2D(GL_TEXTURE_2D, 0, sf->glInternalFormat,
517  img->getSize().x, img->getSize().y,
518  0, sf->glFormat, sf->glType, img->getPtr());
519 
520  glBindTexture(GL_TEXTURE_2D, oldTex);
522 
523  // Clean up.
524 
525  delete converted;
526  return tex;
527 }
528 
529 //------------------------------------------------------------------------
530 
531 ImageFormat Image::chooseCudaFormat(CUDA_ARRAY_DESCRIPTOR* desc, ImageFormat::ID desiredFormat) const
532 {
533 #if (!FW_USE_CUDA)
534 
535  FW_UNREF(desc);
536  FW_UNREF(desiredFormat);
537  fail("Image::chooseCudaFormat(): Built without FW_USE_CUDA!");
538  return m_format;
539 
540 #else
541 
542  // Gather requirements.
543 
544  ImageFormat refFormat = m_format;
545  if (desiredFormat != ImageFormat::ID_Max)
546  refFormat = desiredFormat;
547 
548  int numChannels = min(refFormat.getNumChannels(), 4);
549  int channelBits = 0;
550  bool isFloat = false;
551  for (int i = 0; i < numChannels; i++)
552  {
553  const ImageFormat::Channel& chan = refFormat.getChannel(i);
554  channelBits = max(channelBits, chan.fieldSize);
555  isFloat = (chan.format == ImageFormat::ChannelFormat_Float);
556  }
557 
558  // Select format.
559 
560  CUarray_format datatype;
561  int wordSize;
562 
563  if (isFloat) datatype = CU_AD_FORMAT_FLOAT, wordSize = 4;
564  else if (channelBits <= 8) datatype = CU_AD_FORMAT_UNSIGNED_INT8, wordSize = 1;
565  else if (channelBits <= 16) datatype = CU_AD_FORMAT_UNSIGNED_INT16, wordSize = 2;
566  else datatype = CU_AD_FORMAT_UNSIGNED_INT32, wordSize = 4;
567 
568  ImageFormat formatA; // word per channel
569  ImageFormat formatB; // single word
570 
571  for (int i = 0; i < numChannels; i++)
572  {
573  const ImageFormat::Channel& ref = refFormat.getChannel(i);
574 
576  chan.type = ref.type;
577  chan.format = (isFloat) ? ImageFormat::ChannelFormat_Float : ref.format;
578 
579  chan.wordOfs = i * wordSize;
580  chan.wordSize = wordSize;
581  chan.fieldOfs = 0;
582  chan.fieldSize = wordSize * 8;
583  formatA.addChannel(chan);
584 
585  chan.wordOfs = 0;
586  chan.wordSize = wordSize * numChannels;
587  chan.fieldOfs = i * wordSize * 8;
588  chan.fieldSize = wordSize * 8;
589  formatB.addChannel(chan);
590  }
591 
592  // Fill in the descriptor.
593 
594  if (desc)
595  {
596  desc->Width = m_size.x;
597  desc->Height = m_size.y;
598  desc->Format = datatype;
599  desc->NumChannels = numChannels;
600  }
601  return (formatB == refFormat) ? formatB : formatA;
602 
603 #endif
604 }
605 
606 //------------------------------------------------------------------------
607 
608 CUarray Image::createCudaArray(ImageFormat::ID desiredFormat) const
609 {
610 #if (!FW_USE_CUDA)
611 
612  FW_UNREF(desiredFormat);
613  fail("Image::createCudaArray(): Built without FW_USE_CUDA!");
614  return NULL;
615 
616 #else
617 
618  // Choose format.
619 
620  CUDA_ARRAY_DESCRIPTOR arrayDesc;
621  ImageFormat cudaFormat = chooseCudaFormat(&arrayDesc, desiredFormat);
622 
623  // Image data not usable directly => convert.
624 
625  Image* converted = NULL;
626  const Image* img = this;
627  if (m_size.min() == 0 || m_format != cudaFormat)
628  {
629  converted = new Image(max(m_size, 1), cudaFormat);
630  converted->set(*this);
631  img = converted;
632  arrayDesc.Width = img->getSize().x;
633  arrayDesc.Height = img->getSize().y;
634  }
635 
636  // Create CUDA array.
637 
639 
640  CUarray cudaArray;
641  CudaModule::checkError("cuArrayCreate", cuArrayCreate(&cudaArray, &arrayDesc));
642 
643  CUDA_MEMCPY2D copyDesc;
644  copyDesc.srcXInBytes = 0;
645  copyDesc.srcY = 0;
646  copyDesc.srcMemoryType = CU_MEMORYTYPE_HOST;
647  copyDesc.srcHost = img->getPtr();
648  copyDesc.srcPitch = img->getSize().x * 4;
649  copyDesc.dstXInBytes = 0;
650  copyDesc.dstY = 0;
651  copyDesc.dstMemoryType = CU_MEMORYTYPE_ARRAY;
652  copyDesc.dstArray = cudaArray;
653  copyDesc.WidthInBytes = img->getSize().x * 4;
654  copyDesc.Height = img->getSize().y;
655 
656  CudaModule::checkError("cuMemcpy2D", cuMemcpy2D(&copyDesc));
657 
658  // Clean up.
659 
660  delete converted;
661  return cudaArray;
662 
663 #endif
664 }
665 
666 //------------------------------------------------------------------------
667 // Implements a polyphase filter with round-down semantics from:
668 //
669 // Non-Power-of-Two Mipmapping
670 // (NVIDIA whitepaper)
671 // http://developer.nvidia.com/object/np2_mipmapping.html
672 
674 {
675  // 1x1 or smaller => Bail out.
676 
677  int area = m_size.x * m_size.y;
678  if (area <= 1)
679  return NULL;
680 
681  // Choose filter dimensions.
682 
683  int fw = (m_size.x == 1) ? 1 : ((m_size.x & 1) == 0) ? 2 : 3;
684  int fh = (m_size.y == 1) ? 1 : ((m_size.y & 1) == 0) ? 2 : 3;
685  Vec2i resSize = max(m_size >> 1, 1);
686  int halfArea = area >> 1;
687 
688  // Allocate temporary scanline buffer and result image.
689 
690  Image tmp(Vec2i(m_size.x, fh), ImageFormat::ABGR_8888);
691  Image* res = new Image(resSize, ImageFormat::ABGR_8888);
692  U32* resPtr = (U32*)res->getMutablePtr();
693 
694  // Process each scanline in the result.
695 
696  for (int y = 0; y < resSize.y; y++)
697  {
698  // Copy source scanlines into the temporary buffer.
699 
700  tmp.set(0, *this, Vec2i(0, y * 2), Vec2i(m_size.x, fh));
701 
702  // Choose weights along the Y-axis.
703 
704  Vec3i wy(resSize.y);
705  if (fh == 3)
706  wy = Vec3i(resSize.y - y, resSize.y, y + 1);
707 
708  // Process each pixel in the result.
709 
710  for (int x = 0; x < resSize.x; x++)
711  {
712  // Choose weights along the X-axis.
713 
714  Vec3i wx(resSize.x);
715  if (fw == 3)
716  wx = Vec3i(resSize.x - x, resSize.x, x + 1);
717 
718  // Compute weighted average of pixel values.
719 
720  Vec4i sum = 0;
721  const U32* tmpPtr = (const U32*)tmp.getPtr(Vec2i(x * 2, 0));
722 
723  for (int yy = 0; yy < fh; yy++)
724  {
725  for (int xx = 0; xx < fw; xx++)
726  {
727  U32 abgr = tmpPtr[xx];
728  int weight = wx[xx] * wy[yy];
729  sum.x += (abgr & 0xFF) * weight;
730  sum.y += ((abgr >> 8) & 0xFF) * weight;
731  sum.z += ((abgr >> 16) & 0xFF) * weight;
732  sum.w += (abgr >> 24) * weight;
733  }
734  tmpPtr += m_size.x;
735  }
736 
737  sum = (sum + halfArea) / area;
738  *resPtr++ = sum.x | (sum.y << 8) | (sum.z << 16) | (sum.w << 24);
739  }
740  }
741  return res;
742 }
743 
744 //------------------------------------------------------------------------
745 
746 void Image::init(const Vec2i& size, const ImageFormat& format)
747 {
748  FW_ASSERT(size.min() >= 0);
749  m_size = size;
750  m_format = format;
751  m_channelTmp.resize(m_format.getNumChannels());
752 }
753 
754 //------------------------------------------------------------------------
755 
756 void Image::createBuffer(void)
757 {
758  m_stride = m_size.x * m_format.getBPP();
759  m_buffer = new Buffer;
760  m_buffer->resize(m_stride * m_size.y);
761  m_ownBuffer = true;
762  m_offset = 0;
763 }
764 
765 //------------------------------------------------------------------------
766 
767 void Image::replicatePixel(void)
768 {
769  if (m_size.min() == 0)
770  return;
771 
772  int bpp = getBPP();
773  U8* ptr = getMutablePtr();
774  int scanBytes = m_size.x * bpp;
775 
776  for (int x = 1; x < m_size.x; x++)
777  memcpy(ptr + x * bpp, ptr, bpp);
778  for (int y = 1; y < m_size.y; y++)
779  memcpy(ptr + y * m_stride, ptr, scanBytes);
780 }
781 
782 //------------------------------------------------------------------------
783 
784 bool Image::canBlitDirectly(const ImageFormat& format)
785 {
786  switch (format.getID())
787  {
788  case ImageFormat::R8_G8_B8: return true;
789  case ImageFormat::R8_G8_B8_A8: return true;
790  case ImageFormat::A8: return true;
791  case ImageFormat::XBGR_8888: return true;
792  case ImageFormat::ABGR_8888: return true;
793 
794  case ImageFormat::RGB_565: return true;
795  case ImageFormat::RGBA_5551: return true;
796 
797  case ImageFormat::RGB_Vec3f: return true;
798  case ImageFormat::RGBA_Vec4f: return true;
799  case ImageFormat::A_F32: return true;
800 
801  default: return false;
802  }
803 }
804 
805 //------------------------------------------------------------------------
806 
807 bool Image::canBlitThruABGR(const ImageFormat& format)
808 {
809  switch (format.getID())
810  {
811  case ImageFormat::R8_G8_B8: return true;
812  case ImageFormat::R8_G8_B8_A8: return true;
813  case ImageFormat::A8: return true;
814  case ImageFormat::XBGR_8888: return true;
815  case ImageFormat::ABGR_8888: return true;
816 
817  case ImageFormat::RGB_565: return true;
818  case ImageFormat::RGBA_5551: return true;
819 
820  case ImageFormat::RGB_Vec3f: return false;
821  case ImageFormat::RGBA_Vec4f: return false;
822  case ImageFormat::A_F32: return false;
823 
824  default: return false;
825  }
826 }
827 
828 //------------------------------------------------------------------------
829 
830 void Image::blit(
831  const ImageFormat& dstFormat, U8* dstPtr, S64 dstStride,
832  const ImageFormat& srcFormat, const U8* srcPtr, S64 srcStride,
833  const Vec2i& size)
834 {
835  FW_ASSERT(size.min() >= 0);
836  if (size.min() == 0)
837  return;
838 
839  // Same format?
840 
841  if (dstFormat == srcFormat)
842  {
843  int scanBytes = size.x * dstFormat.getBPP();
844  for (int y = 0; y < size.y; y++)
845  memcpy(dstPtr + dstStride * y, srcPtr + srcStride * y, scanBytes);
846  return;
847  }
848 
849  // To ABGR_8888?
850 
851  if (dstFormat.getID() == ImageFormat::ABGR_8888 && canBlitDirectly(srcFormat))
852  {
853  for (int y = 0; y < size.y; y++)
854  blitToABGR((U32*)(dstPtr + dstStride * y), srcFormat, srcPtr + srcStride * y, size.x);
855  return;
856  }
857 
858  // From ABGR_8888?
859 
860  if (srcFormat.getID() == ImageFormat::ABGR_8888 && canBlitDirectly(dstFormat))
861  {
862  for (int y = 0; y < size.y; y++)
863  blitFromABGR(dstFormat, dstPtr + dstStride * y, (const U32*)(srcPtr + srcStride * y), size.x);
864  return;
865  }
866 
867  // From integer-based format to another => convert thru ABGR_8888.
868 
869  if (canBlitDirectly(srcFormat) && canBlitDirectly(dstFormat) && canBlitThruABGR(srcFormat))
870  {
871  Array<U32> tmp(NULL, size.x);
872  for (int y = 0; y < size.y; y++)
873  {
874  blitToABGR(tmp.getPtr(), srcFormat, srcPtr + srcStride * y, size.x);
875  blitFromABGR(dstFormat, dstPtr + dstStride * y, tmp.getPtr(), size.x);
876  }
877  return;
878  }
879 
880  // General case.
881 
882  S64 dstBPP = dstFormat.getBPP();
883  S64 srcBPP = srcFormat.getBPP();
884  Array<F32> dv(NULL, dstFormat.getNumChannels());
885  Array<F32> sv(NULL, srcFormat.getNumChannels());
886  Array<Vec2i> map;
887 
888  for (int i = 0; i < dstFormat.getNumChannels(); i++)
889  {
890  ImageFormat::ChannelType t = dstFormat.getChannel(i).type;
891  dv[i] = (t == ImageFormat::ChannelType_A) ? 1.0f : 0.0f;
892  int si = srcFormat.findChannel(t);
893  if (si != -1)
894  map.add(Vec2i(i, si));
895  }
896 
897  for (int y = 0; y < size.y; y++)
898  {
899  U8* dstPixel = dstPtr + dstStride * y;
900  const U8* srcPixel = srcPtr + srcStride * y;
901 
902  for (int x = 0; x < size.x; x++)
903  {
904  getChannels(sv.getPtr(), srcPixel, srcFormat, 0, sv.getSize());
905  for (int i = 0; i < map.getSize(); i++)
906  dv[map[i].x] = sv[map[i].y];
907  setChannels(dstPixel, dv.getPtr(), dstFormat, 0, dv.getSize());
908 
909  dstPixel += dstBPP;
910  srcPixel += srcBPP;
911  }
912  }
913 }
914 
915 //------------------------------------------------------------------------
916 
917 void Image::blitToABGR(U32* dstPtr, const ImageFormat& srcFormat, const U8* srcPtr, int width)
918 {
919  FW_ASSERT(width > 0);
920  FW_ASSERT(dstPtr && srcPtr);
921  FW_ASSERT(canBlitDirectly(srcFormat));
922 
923  const U8* s8 = srcPtr;
924  const U16* s16 = (const U16*)srcPtr;
925  const Vec3f* sv3 = (const Vec3f*)srcPtr;
926  const Vec4f* sv4 = (const Vec4f*)srcPtr;
927  const F32* sf = (const F32*)srcPtr;
928 
929  switch (srcFormat.getID())
930  {
931  case ImageFormat::R8_G8_B8: for (int x = width; x > 0; x--) { *dstPtr++ = s8[0] | (s8[1] << 8) | (s8[2] << 16) | 0xFF000000; s8 += 3; } break;
932  case ImageFormat::R8_G8_B8_A8: for (int x = width; x > 0; x--) { *dstPtr++ = s8[0] | (s8[1] << 8) | (s8[2] << 16) | (s8[3] << 24); s8 += 4; } break;
933  case ImageFormat::A8: for (int x = width; x > 0; x--) *dstPtr++ = *s8++ << 24; break;
934  case ImageFormat::XBGR_8888: memcpy(dstPtr, srcPtr, width * sizeof(U32)); break;
935  case ImageFormat::ABGR_8888: memcpy(dstPtr, srcPtr, width * sizeof(U32)); break;
936 
937  case ImageFormat::RGB_565: for (int x = width; x > 0; x--) { U16 v = *s16++; *dstPtr++ = RGB_565_TO_ABGR_8888(v); } break;
938  case ImageFormat::RGBA_5551: for (int x = width; x > 0; x--) { U16 v = *s16++; *dstPtr++ = RGBA_5551_TO_ABGR_8888(v); } break;
939 
940  case ImageFormat::RGB_Vec3f: for (int x = width; x > 0; x--) *dstPtr++ = Vec4f(*sv3++, 1.0f).toABGR(); break;
941  case ImageFormat::RGBA_Vec4f: for (int x = width; x > 0; x--) *dstPtr++ = (sv4++)->toABGR(); break;
942  case ImageFormat::A_F32: for (int x = width; x > 0; x--) *dstPtr++ = clamp((int)(*sf++ * 255.0f + 0.5f), 0x00, 0xFF) << 24; break;
943 
944  default: FW_ASSERT(false); break;
945  }
946 }
947 
948 //------------------------------------------------------------------------
949 
950 void Image::blitFromABGR(const ImageFormat& dstFormat, U8* dstPtr, const U32* srcPtr, int width)
951 {
952  FW_ASSERT(width > 0);
953  FW_ASSERT(dstPtr && srcPtr);
954  FW_ASSERT(canBlitDirectly(dstFormat));
955 
956  U8* d8 = dstPtr;
957  U16* d16 = (U16*)dstPtr;
958  Vec3f* dv3 = (Vec3f*)dstPtr;
959  Vec4f* dv4 = (Vec4f*)dstPtr;
960  F32* df = (F32*)dstPtr;
961 
962  switch (dstFormat.getID())
963  {
964  case ImageFormat::R8_G8_B8: for (int x = width; x > 0; x--) { U32 v = *srcPtr++; *d8++ = (U8)v; *d8++ = (U8)(v >> 8); *d8++ = (U8)(v >> 16); } break;
965  case ImageFormat::R8_G8_B8_A8: for (int x = width; x > 0; x--) { U32 v = *srcPtr++; *d8++ = (U8)v; *d8++ = (U8)(v >> 8); *d8++ = (U8)(v >> 16); *d8++ = (U8)(v >> 24); } break;
966  case ImageFormat::A8: for (int x = width; x > 0; x--) *d8++ = (U8)(*srcPtr++ >> 24); break;
967  case ImageFormat::XBGR_8888: memcpy(dstPtr, srcPtr, width * sizeof(U32)); break;
968  case ImageFormat::ABGR_8888: memcpy(dstPtr, srcPtr, width * sizeof(U32)); break;
969 
970  case ImageFormat::RGB_565: for (int x = width; x > 0; x--) { U32 v = *srcPtr++; *d16++ = ABGR_8888_TO_RGB_565(v); } break;
971  case ImageFormat::RGBA_5551: for (int x = width; x > 0; x--) { U32 v = *srcPtr++; *d16++ = ABGR_8888_TO_RGBA_5551(v); } break;
972 
973  case ImageFormat::RGB_Vec3f: for (int x = width; x > 0; x--) *dv3++ = Vec4f::fromABGR(*srcPtr++).getXYZ(); break;
974  case ImageFormat::RGBA_Vec4f: for (int x = width; x > 0; x--) *dv4++ = Vec4f::fromABGR(*srcPtr++); break;
975  case ImageFormat::A_F32: for (int x = width; x > 0; x--) *df++ = (F32)(*srcPtr++ >> 24) / 255.0f; break;
976 
977  default: FW_ASSERT(false); break;
978  }
979 }
980 
981 //------------------------------------------------------------------------
982 
983 void Image::getChannels(F32* values, const U8* pixelPtr, const ImageFormat& format, int first, int num)
984 {
985  FW_ASSERT(num >= 0);
986  FW_ASSERT((values && pixelPtr) || !num);
987  FW_ASSERT(first >= 0 && first + num <= format.getNumChannels());
988 
989  for (int i = 0; i < num; i++)
990  {
991  const ImageFormat::Channel& c = format.getChannel(i + first);
992  const U8* wordPtr = pixelPtr + c.wordOfs;
993  U32 field;
994  switch (c.wordSize)
995  {
996  case 1: field = *wordPtr; break;
997  case 2: field = *(const U16*)wordPtr; break;
998  case 4: field = *(const U32*)wordPtr; break;
999  default: FW_ASSERT(false); return;
1000  }
1001  field >>= c.fieldOfs;
1002 
1003  U32 mask = (1 << c.fieldSize) - 1;
1004  switch (c.format)
1005  {
1006  case ImageFormat::ChannelFormat_Clamp: values[i] = (F32)(field & mask) / (F32)mask; break;
1007  case ImageFormat::ChannelFormat_Int: values[i] = (F32)(field & mask); break;
1008  case ImageFormat::ChannelFormat_Float: FW_ASSERT(c.fieldSize == 32); values[i] = bitsToFloat(field); break;
1009  default: FW_ASSERT(false); return;
1010  }
1011  }
1012 }
1013 
1014 //------------------------------------------------------------------------
1015 
1016 void Image::setChannels(U8* pixelPtr, const F32* values, const ImageFormat& format, int first, int num)
1017 {
1018  FW_ASSERT(num >= 0);
1019  FW_ASSERT((pixelPtr && values) || !num);
1020  FW_ASSERT(first >= 0 && first + num <= format.getNumChannels());
1021 
1022  memset(pixelPtr, 0, format.getBPP());
1023 
1024  for (int i = 0; i < num; i++)
1025  {
1026  const ImageFormat::Channel& c = format.getChannel(i + first);
1027  U32 mask = (1 << c.fieldSize) - 1;
1028  U32 field;
1029  switch (c.format)
1030  {
1031  case ImageFormat::ChannelFormat_Clamp: field = min((U32)max(values[i] * (F32)mask + 0.5f, 0.0f), mask); break;
1032  case ImageFormat::ChannelFormat_Int: field = min((U32)max(values[i] + 0.5f, 0.0f), mask); break;
1033  case ImageFormat::ChannelFormat_Float: FW_ASSERT(c.fieldSize == 32); field = floatToBits(values[i]); break;
1034  default: FW_ASSERT(false); return;
1035  }
1036  field <<= c.fieldOfs;
1037 
1038  U8* wordPtr = pixelPtr + c.wordOfs;
1039  switch (c.wordSize)
1040  {
1041  case 1: *wordPtr |= (U8)field; break;
1042  case 2: *(U16*)wordPtr |= (U16)field; break;
1043  case 4: *(U32*)wordPtr |= field; break;
1044  default: FW_ASSERT(false); return;
1045  }
1046  }
1047 }
1048 
1049 //------------------------------------------------------------------------
1050 
1051 Image* FW::importImage(const String& fileName)
1052 {
1053  String lower = fileName.toLower();
1054 
1055 #define STREAM(CALL) { File file(fileName, File::Read); BufferedInputStream stream(file); return CALL; }
1056  if (lower.endsWith(".bin")) STREAM(importBinaryImage(stream))
1057  if (lower.endsWith(".png")) STREAM(importLodePngImage(stream))
1058  if (lower.endsWith(".tga") || lower.endsWith(".targa")) STREAM(importTargaImage(stream))
1059  if (lower.endsWith(".tif") || lower.endsWith(".tiff")) STREAM(importTiffImage(stream))
1060  if (lower.endsWith(".bmp")) STREAM(importBmpImage(stream))
1061 #undef STREAM
1062 
1063  setError("importImage(): Unsupported file extension '%s'!", fileName.getPtr());
1064  return NULL;
1065 }
1066 
1067 //------------------------------------------------------------------------
1068 
1069 void FW::exportImage(const String& fileName, const Image* image)
1070 {
1071  FW_ASSERT(image);
1072  String lower = fileName.toLower();
1073 
1074 #define STREAM(CALL) { File file(fileName, File::Create); BufferedOutputStream stream(file); CALL; stream.flush(); return; }
1075  if (lower.endsWith(".bin")) STREAM(exportBinaryImage(stream, image))
1076  if (lower.endsWith(".png")) STREAM(exportLodePngImage(stream, image))
1077  if (lower.endsWith(".png")) STREAM(exportRawPngImage(stream, image))
1078  if (lower.endsWith(".tga") || lower.endsWith(".targa")) STREAM(exportTargaImage(stream, image))
1079  if (lower.endsWith(".tif") || lower.endsWith(".tiff")) STREAM(exportTiffImage(stream, image))
1080  if (lower.endsWith(".bmp")) STREAM(exportBmpImage(stream, image))
1081 #undef STREAM
1082 
1083  setError("exportImage(): Unsupported file extension '%s'!", fileName.getPtr());
1084 }
1085 
1086 //------------------------------------------------------------------------
1087 
1089 {
1090  return
1091  "png:PNG Image,"
1092  "tga;targa:Targa Image,"
1093  "tif;tiff:TIFF Image,"
1094  "bmp:BMP Image,"
1095  "bin:Binary Image";
1096 }
1097 
1098 //------------------------------------------------------------------------
1099 
1101 {
1102  return
1103  "png:PNG Image,"
1104  "tga;targa:Targa Image,"
1105  "tif;tiff:TIFF Image,"
1106  "bmp:BMP Image,"
1107  "bin:Binary Image";
1108 }
1109 
1110 //------------------------------------------------------------------------
void exportImage(const String &fileName, const Image *image)
Definition: Image.cpp:1069
#define FW_UNREF(X)
Definition: Defs.hpp:78
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei const GLvoid pointer GLuint GLuint const GLchar name GLenum GLsizei GLenum GLsizei GLsizei height GLenum GLuint renderbuffer GLenum GLenum GLint params GLuint GLsizei range GLuint GLsizei const GLubyte GLsizei GLenum const GLvoid coords GLuint GLsizei GLsizei GLsizei const GLubyte GLsizei GLenum const GLvoid coords GLuint GLenum GLsizei const GLvoid pathString GLuint GLenum const GLvoid GLbitfield GLuint GLsizei GLenum GLuint GLfloat emScale GLuint GLuint srcPath GLuint GLuint GLenum const GLfloat transformValues GLuint GLenum GLint value GLuint GLenum GLfloat value GLenum GLint GLuint mask
Definition: DLLImports.inl:400
U32 floatToBits(F32 a)
Definition: Math.hpp:95
#define ABGR_8888_TO_RGBA_5551(V)
Definition: Image.cpp:74
bool operator==(const ImageFormat &other) const
Definition: Image.cpp:226
#define NULL
Definition: Defs.hpp:39
#define GL_GENERATE_MIPMAP
Definition: DLLImports.hpp:163
bool endsWith(const String &str) const
Definition: String.cpp:273
const char * getPtr(void) const
Definition: String.hpp:51
void addChannel(const Channel &channel)
Definition: Image.cpp:168
#define C16(TYPE, OFS, SIZE)
Definition: Image.cpp:43
#define C32(TYPE, OFS)
Definition: Image.cpp:44
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer
Definition: DLLImports.inl:315
int getNumChannels(void) const
Definition: Image.cpp:119
const StaticFormat * getStaticFormat(void) const
Definition: Image.cpp:102
#define GL_ALPHA32F_ARB
Definition: DLLImports.hpp:151
void setError(const char *fmt,...)
Definition: Defs.cpp:253
void ** ptr
Definition: DLLImports.cpp:74
#define RGBA_5551_TO_ABGR_8888(V)
Definition: Image.cpp:73
Image * importImage(const String &fileName)
Definition: Image.cpp:1051
#define GL_UNSIGNED_SHORT_5_5_5_1
Definition: DLLImports.hpp:186
void clear(void)
Definition: Image.cpp:159
#define GL_RGB32F
Definition: DLLImports.hpp:174
#define STREAM(CALL)
#define GL_RGBA32F
Definition: DLLImports.hpp:175
~Image(void)
Definition: Image.cpp:274
U32 getABGR(const Vec2i &pos) const
Definition: Image.cpp:282
U32 toABGR(void) const
Definition: Math.cpp:45
CUarray createCudaArray(ImageFormat::ID desiredFormat=ImageFormat::ID_Max) const
Definition: Image.cpp:608
static void checkErrors(void)
Definition: GLContext.cpp:1003
ID getID(void) const
Definition: Image.cpp:78
FW_CUDA_FUNC Vec3f getXYZ(void) const
Definition: Math.hpp:365
Image(const Vec2i &size, const ImageFormat &format=ImageFormat::ABGR_8888)
Definition: Image.hpp:135
void exportTargaImage(OutputStream &stream, const Image *image)
S64 getSize(void) const
Definition: Buffer.hpp:69
const U8 * getPtr(const Vec2i &pos=0) const
Definition: Image.hpp:150
void exportBmpImage(OutputStream &stream, const Image *image)
Definition: ImageBmpIO.cpp:292
String toLower(void) const
Definition: String.cpp:245
#define ABGR_8888_TO_RGB_565(V)
Definition: Image.cpp:71
void exportRawPngImage(OutputStream &stream, const Image *image)
ID getGLFormat(void) const
Definition: Image.cpp:184
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat x
Definition: DLLImports.inl:363
Image * importBinaryImage(InputStream &stream)
#define C8(TYPE, OFS)
Definition: Image.cpp:42
static void checkError(const char *funcName, CUresult res)
Definition: CudaModule.cpp:487
void exportTiffImage(OutputStream &stream, const Image *image)
Image * importTiffImage(InputStream &stream)
Definition: ImageTiffIO.cpp:81
FW_CUDA_FUNC T sum(const VectorBase< T, L, S > &v)
Definition: Math.hpp:463
float F32
Definition: Defs.hpp:89
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat y
Definition: DLLImports.inl:363
#define CF32(TYPE, OFS)
Definition: Image.cpp:45
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height cuArrayCreate
Definition: DLLImports.inl:138
GLuint createGLTexture(ImageFormat::ID desiredFormat=ImageFormat::ID_Max, bool generateMipmaps=true) const
Definition: Image.cpp:475
void getChannels(F32 *values, const Vec2i &pos, int first, int num) const
Definition: Image.hpp:167
void set(const Vec2i &dstPos, const Image &src, const Vec2i &srcPos, const Vec2i &size)
Definition: Image.hpp:157
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v
Definition: DLLImports.inl:329
Image * downscale2x(void) const
Definition: Image.cpp:673
#define RGB_565_TO_ABGR_8888(V)
Definition: Image.cpp:70
void setVec4f(const Vec2i &pos, const Vec4f &value)
Definition: Image.cpp:406
void setABGR(const Vec2i &pos, U32 value)
Definition: Image.cpp:329
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
Definition: Math.hpp:461
Vec4f getVec4f(const Vec2i &pos) const
Definition: Image.cpp:369
bool contains(const Vec2i &pos, const Vec2i &size) const
Definition: Image.hpp:141
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
Definition: Math.hpp:462
ChannelType type
Definition: Image.hpp:79
#define FW_ASSERT(X)
Definition: Defs.hpp:67
void flipY(void)
Definition: Image.cpp:459
Image * importBmpImage(InputStream &stream)
Definition: ImageBmpIO.cpp:36
U8 * getMutablePtr(const Vec2i &pos=0)
Definition: Image.hpp:151
Image * importLodePngImage(InputStream &stream)
#define GL_UNSIGNED_SHORT_5_6_5
Definition: DLLImports.hpp:187
const Channel & getChannel(int idx) const
Definition: Image.cpp:127
signed __int64 S64
Definition: Defs.hpp:98
unsigned int U32
Definition: Defs.hpp:85
ImageFormat chooseCudaFormat(CUDA_ARRAY_DESCRIPTOR *desc=NULL, ImageFormat::ID desiredFormat=ImageFormat::ID_Max) const
Definition: Image.cpp:531
void flipX(void)
Definition: Image.cpp:440
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei stride
Definition: DLLImports.inl:365
F32 bitsToFloat(U32 a)
Definition: Math.hpp:96
const Vec2i & getSize(void) const
Definition: Image.hpp:143
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction f
Definition: DLLImports.inl:88
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value
Definition: DLLImports.inl:84
String getImageImportFilter(void)
Definition: Image.cpp:1088
Image * importTargaImage(InputStream &stream)
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: DLLImports.inl:349
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei width
Definition: DLLImports.inl:347
#define FW_ARRAY_SIZE(X)
Definition: Defs.hpp:79
void set(const ImageFormat &other)
Definition: Image.cpp:147
unsigned char U8
Definition: Defs.hpp:83
void exportLodePngImage(OutputStream &stream, const Image *image)
unsigned short U16
Definition: Defs.hpp:84
int getBPP(void) const
Definition: Image.hpp:145
static Vec4f fromABGR(U32 abgr)
Definition: Math.cpp:34
FW_CUDA_FUNC void swap(T &a, T &b)
Definition: Defs.hpp:183
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void * p
Definition: DLLImports.inl:66
static void staticInit(void)
Definition: CudaModule.cpp:311
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type
Definition: DLLImports.inl:323
void setChannels(const Vec2i &pos, const F32 *values, int first, int num)
Definition: Image.hpp:171
void exportBinaryImage(OutputStream &stream, const Image *image)
const T * getPtr(S idx=0) const
Definition: Array.hpp:202
int findChannel(ChannelType type) const
Definition: Image.cpp:136
void fail(const char *fmt,...)
Definition: Defs.cpp:304
ChannelFormat format
Definition: Image.hpp:80
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void * image
Definition: DLLImports.inl:60
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
Definition: DLLImports.inl:319
void resize(S64 size)
Definition: Buffer.hpp:82
static void staticInit(void)
Definition: GLContext.cpp:894
int getBPP(void) const
Definition: Image.cpp:111
void resize(S size)
Definition: Array.hpp:366
S getSize(void) const
Definition: Array.hpp:188
FW_CUDA_FUNC T min(void) const
Definition: Math.hpp:146
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei const GLvoid pointer GLuint GLuint const GLchar name GLenum GLsizei GLenum GLsizei GLsizei height GLenum GLuint renderbuffer GLenum GLenum GLint params GLuint GLsizei range GLuint GLsizei const GLubyte GLsizei GLenum const GLvoid coords GLuint GLsizei GLsizei GLsizei const GLubyte GLsizei GLenum const GLvoid coords GLuint GLenum GLsizei const GLvoid pathString GLuint GLenum const GLvoid GLbitfield GLuint GLsizei GLenum GLuint GLfloat emScale GLuint GLuint srcPath GLuint GLuint GLenum const GLfloat transformValues GLuint GLenum GLint value GLuint GLenum GLfloat value GLenum GLint ref
Definition: DLLImports.inl:400
String getImageExportFilter(void)
Definition: Image.cpp:1100