Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "qtofflinegl.h"
Toshihiro Shimizu 890ddd
#include <traster.h></traster.h>
Toshihiro Shimizu 890ddd
#include <tconvert.h></tconvert.h>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun_iwasawa 0cae24
#if 0  // was _WIN32, this function not used
Toshihiro Shimizu 890ddd
2fc36c
static void swapRedBlueChannels(
Shinya Kitaoka 120a6e
    void *buffer,
Shinya Kitaoka 120a6e
    int bufferSize)  // Flips The Red And Blue Bytes (WidthxHeight)
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
  void *b = buffer;  // Pointer To The Buffer
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef x64
Shinya Kitaoka 120a6e
  int size   = bufferSize;
Shinya Kitaoka 120a6e
  UCHAR *pix = (UCHAR *)b;
Shinya Kitaoka 120a6e
  while (size > 0) {
Shinya Kitaoka 120a6e
    UCHAR r    = *pix;
Shinya Kitaoka 120a6e
    UCHAR b    = *(pix + 2);
Shinya Kitaoka 120a6e
    *pix       = b;
Shinya Kitaoka 120a6e
    *(pix + 2) = r;
Shinya Kitaoka 120a6e
    pix += 4;
Shinya Kitaoka 120a6e
    size--;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
  __asm        // Assembler Code To Follow
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
		mov ecx, bufferSize  // Counter Set To Dimensions Of Our Memory Block
Shinya Kitaoka 120a6e
			mov ebx, b  // Points ebx To Our Data (b)
Shinya Kitaoka 120a6e
			label:  // Label Used For Looping
Shinya Kitaoka 120a6e
			mov al,[ebx+0]  // Loads Value At ebx Into al
Shinya Kitaoka 120a6e
			mov ah,[ebx+2]  // Loads Value At ebx+2 Into ah
Shinya Kitaoka 120a6e
			mov [ebx+2],al  // Stores Value In al At ebx+2
Shinya Kitaoka 120a6e
			mov [ebx+0],ah  // Stores Value In ah At ebx
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
			add ebx,4  // Moves Through The Data By 4 Bytes
Shinya Kitaoka 120a6e
			dec ecx  // Decreases Our Loop Counter
Shinya Kitaoka 120a6e
			jnz label  // If Not Zero Jump Back To Label
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if defined(MACOSX)
Toshihiro Shimizu 890ddd
#if defined(powerpc)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void rightRotateBits(UCHAR *buf, int bufferSize) {
Shinya Kitaoka 120a6e
  UINT *buffer = (UINT *)buf;
Shinya Kitaoka 120a6e
  UINT app;
Shinya Kitaoka 120a6e
  for (int i = 0; i < bufferSize; i++, buffer++) {
Shinya Kitaoka 120a6e
    app     = *buffer;
Shinya Kitaoka 120a6e
    *buffer = app >> 8 | app << 24;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
void rightRotateBits(UCHAR *buf, int bufferSize) {
Shinya Kitaoka 120a6e
  UINT *buffer = (UINT *)buf;
Shinya Kitaoka 120a6e
  UINT app;
Shinya Kitaoka 120a6e
  for (int i = 0; i < bufferSize; i++, buffer++) {
Shinya Kitaoka 120a6e
    app     = *buffer;
Shinya Kitaoka 120a6e
    *buffer = (app >> 16 & 0x000000ff) | (app << 16 & 0x00ff0000) |
Shinya Kitaoka 120a6e
              (app & 0xff00ff00);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// QtOfflineGL : implem. offlineGL usando QT
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QtOfflineGL::QtOfflineGL(TDimension rasterSize,
Shinya Kitaoka 120a6e
                         std::shared_ptr<tofflinegl::imp> shared)</tofflinegl::imp>
Shinya Kitaoka 120a6e
    : TOfflineGL::Imp(rasterSize.lx, rasterSize.ly)
Shinya Kitaoka 120a6e
    , m_context(0)
Shinya Kitaoka 120a6e
    , m_oldContext(0) {
Shinya Kitaoka 120a6e
  createContext(rasterSize, std::move(shared));
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
makeCurrent();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
glClearColor(0.0f,0.0f,0.0f,0.0f);
Shinya Kitaoka 120a6e
glClear(GL_COLOR_BUFFER_BIT);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
doneCurrent();
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QtOfflineGL::~QtOfflineGL() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGL::createContext(TDimension rasterSize,
Shinya Kitaoka 120a6e
                                std::shared_ptr<tofflinegl::imp> shared) {</tofflinegl::imp>
Shinya Kitaoka 120a6e
  // Imposto il formato dei Pixel (pixelFormat)
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
   32,                    // 32-bit color depth
Shinya Kitaoka 120a6e
   0, 0, 0, 0, 0, 0,      // color bits ignored
Shinya Kitaoka 120a6e
   8,                     // no alpha buffer
Shinya Kitaoka 120a6e
   0,                     // shift bit ignored
Shinya Kitaoka 120a6e
   0,                     // no accumulation buffer
Shinya Kitaoka 120a6e
   0, 0, 0, 0,            // accum bits ignored
Shinya Kitaoka 120a6e
   32,                    // 32-bit z-buffer
Shinya Kitaoka 120a6e
   32,                    // max stencil buffer
Shinya Kitaoka 120a6e
   0,                     // no auxiliary buffer
Shinya Kitaoka 120a6e
   PFD_MAIN_PLANE,        // main layer
Shinya Kitaoka 120a6e
   0,                     // reserved
Shinya Kitaoka 120a6e
   0, 0, 0                // layer masks ignored
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
   ATTENZIONE !! SU MAC IL FORMATO E' DIVERSO (casomai possiamo mettere un
Shinya Kitaoka 120a6e
   ifdef)
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
   SPECIFICHE  MAC = depth_size 24, stencil_size 8, alpha_size 1
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QGLFormat fmt;
Toshihiro Shimizu 890ddd
Campbell Barton d869b5
#if defined(_WIN32)
Shinya Kitaoka 120a6e
  fmt.setAlphaBufferSize(8);
Shinya Kitaoka 120a6e
  fmt.setAlpha(true);
Shinya Kitaoka 120a6e
  fmt.setRgba(true);
Shinya Kitaoka 120a6e
  fmt.setDepthBufferSize(32);
Shinya Kitaoka 120a6e
  fmt.setDepth(true);
Shinya Kitaoka 120a6e
  fmt.setStencilBufferSize(32);
Shinya Kitaoka 120a6e
  fmt.setStencil(true);
Shinya Kitaoka 120a6e
  fmt.setAccum(false);
Shinya Kitaoka 120a6e
  fmt.setPlane(0);
Campbell Barton d869b5
#elif defined(MACOSX)
Shinya Kitaoka 120a6e
  fmt = QGLFormat::defaultFormat();
Shinya Kitaoka 120a6e
  // printf("GL Version: %s\n",glGetString(GL_VERSION));
Shinya Kitaoka 120a6e
  fmt.setVersion(2, 1); /* OSX10.8 では 3.2 だめかも */
Toshihiro Shimizu 890ddd
#if 0
Toshihiro Shimizu 890ddd
  fmt.setAlphaBufferSize(8);
Toshihiro Shimizu 890ddd
  fmt.setAlpha(true);
Toshihiro Shimizu 890ddd
  fmt.setRgba(true);
Toshihiro Shimizu 890ddd
  fmt.setDepthBufferSize(32);
Toshihiro Shimizu 890ddd
  fmt.setDepth(true);
Toshihiro Shimizu 890ddd
  fmt.setStencilBufferSize(8);
Toshihiro Shimizu 890ddd
  fmt.setStencil(true);
Toshihiro Shimizu 890ddd
  fmt.setAccum(false);
Toshihiro Shimizu 890ddd
  fmt.setPlane(0);
Toshihiro Shimizu 890ddd
  fmt.setDirectRendering(false);
Toshihiro Shimizu 890ddd
#endif
Campbell Barton d869b5
#elif defined(LINUX)
Campbell Barton 301bdb
  fmt = QGLFormat::defaultFormat();
Campbell Barton 301bdb
  // printf("GL Version: %s\n",glGetString(GL_VERSION));
Campbell Barton 301bdb
  fmt.setVersion(2, 1); /* XXX? */
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QSurfaceFormat format;
Shinya Kitaoka 120a6e
  format.setProfile(QSurfaceFormat::CompatibilityProfile);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_surface = std::make_shared<qoffscreensurface>();</qoffscreensurface>
Shinya Kitaoka 120a6e
  m_surface->setFormat(format);
Shinya Kitaoka 120a6e
  m_surface->create();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_context = std::make_shared<qopenglcontext>();</qopenglcontext>
Shinya Kitaoka 120a6e
  m_context->setFormat(format);
Shinya Kitaoka 120a6e
  m_context->create();
Shinya Kitaoka 120a6e
  m_context->makeCurrent(m_surface.get());
tomosu 794bf5
Shinya Kitaoka 120a6e
  QOpenGLFramebufferObjectFormat fbo_format;
shun-iwasawa a86fd8
  fbo_format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
Shinya Kitaoka 120a6e
  m_fbo = std::make_shared<qopenglframebufferobject>(rasterSize.lx,</qopenglframebufferobject>
Shinya Kitaoka 120a6e
                                                     rasterSize.ly, fbo_format);
Shinya Kitaoka 120a6e
  m_fbo->bind();
tomosu 794bf5
Shinya Kitaoka 120a6e
  printf("create context:%p [thread:0x%x]\n", m_context.get(),
Shinya Kitaoka 120a6e
         QThread::currentThreadId());
tomosu 794bf5
Shinya Kitaoka 120a6e
  // Creo il contesto OpenGL - assicurandomi che sia effettivamente creato
Shinya Kitaoka 120a6e
  // NOTA: Se il contesto non viene creato, di solito basta ritentare qualche
Shinya Kitaoka 120a6e
  // volta.
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGL::makeCurrent() {
Shinya Kitaoka 120a6e
  if (m_context) {
Shinya Kitaoka 120a6e
    m_context->moveToThread(QThread::currentThread());
Shinya Kitaoka 120a6e
    m_context->makeCurrent(m_surface.get());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGL::doneCurrent() {
Shinya Kitaoka 120a6e
  if (m_context) {
tomosu 8d9526
    m_context->moveToThread(0);
Shinya Kitaoka 120a6e
    m_context->doneCurrent();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGL::saveCurrentContext() {
Shinya Kitaoka 120a6e
  //  m_oldContext = const_cast<qglcontext*>(QGLContext::currentContext());</qglcontext*>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGL::restoreCurrentContext() {
Shinya Kitaoka 120a6e
  //  if(m_oldContext) m_oldContext->makeCurrent();
Shinya Kitaoka 120a6e
  //  m_oldContext = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGL::getRaster(TRaster32P raster) {
Shinya Kitaoka 120a6e
  makeCurrent();
Shinya Kitaoka 120a6e
  glFlush();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int lx = raster->getLx();
Shinya Kitaoka 120a6e
  int ly = raster->getLy();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  raster->lock();
Shinya Kitaoka 120a6e
  raster->copy(TRaster32P(lx, ly, m_fbo->width(),
Shinya Kitaoka 120a6e
                          (TPixelRGBM32 *)m_fbo->toImage(false).bits(), false));
Shinya Kitaoka 120a6e
  raster->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// QGLPixelBuffer::hasOpenGLPbuffers() (statica) -> true se la scheda supporta i
Shinya Kitaoka 120a6e
// PBuffer
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// QtOfflineGLPBuffer : implem. offlineGL usando QT e PBuffer
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QtOfflineGLPBuffer::QtOfflineGLPBuffer(TDimension rasterSize)
Shinya Kitaoka 120a6e
    : TOfflineGL::Imp(rasterSize.lx, rasterSize.ly), m_context(0) {
Shinya Kitaoka 120a6e
  createContext(rasterSize);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  makeCurrent();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Shinya Kitaoka 120a6e
  glClear(GL_COLOR_BUFFER_BIT);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  doneCurrent();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QtOfflineGLPBuffer::~QtOfflineGLPBuffer() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGLPBuffer::createContext(TDimension rasterSize) {
Shinya Kitaoka 120a6e
  // Imposto il formato dei Pixel (pixelFormat)
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
32,                    // 32-bit color depth
Shinya Kitaoka 120a6e
0, 0, 0, 0, 0, 0,      // color bits ignored
Shinya Kitaoka 120a6e
8,                     // no alpha buffer
Shinya Kitaoka 120a6e
0,                     // shift bit ignored
Shinya Kitaoka 120a6e
0,                     // no accumulation buffer
Shinya Kitaoka 120a6e
0, 0, 0, 0,            // accum bits ignored
Shinya Kitaoka 120a6e
32,                    // 32-bit z-buffer
Shinya Kitaoka 120a6e
32,                    // max stencil buffer
Shinya Kitaoka 120a6e
0,                     // no auxiliary buffer
Shinya Kitaoka 120a6e
PFD_MAIN_PLANE,        // main layer
Shinya Kitaoka 120a6e
0,                     // reserved
Shinya Kitaoka 120a6e
0, 0, 0                // layer masks ignored
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
ATTENZIONE !! SU MAC IL FORMATO E' DIVERSO (casomai possiamo mettere un ifdef)
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
SPECIFICHE  MAC = depth_size 24, stencil_size 8, alpha_size 1
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QGLFormat fmt;
Toshihiro Shimizu 890ddd
Campbell Barton 5f15dd
#if defined(_WIN32)
Shinya Kitaoka 120a6e
  fmt.setAlphaBufferSize(8);
Shinya Kitaoka 120a6e
  fmt.setAlpha(false);
Shinya Kitaoka 120a6e
  fmt.setRgba(true);
Shinya Kitaoka 120a6e
  fmt.setDepthBufferSize(32);
Shinya Kitaoka 120a6e
  fmt.setDepth(true);
Shinya Kitaoka 120a6e
  fmt.setStencilBufferSize(32);
Shinya Kitaoka 120a6e
  fmt.setStencil(true);
Shinya Kitaoka 120a6e
  fmt.setAccum(false);
Shinya Kitaoka 120a6e
  fmt.setPlane(0);
Campbell Barton d869b5
#elif defined(MACOSX)
Shinya Kitaoka 120a6e
  fmt.setAlphaBufferSize(1);
Shinya Kitaoka 120a6e
  fmt.setAlpha(false);
Shinya Kitaoka 120a6e
  fmt.setRgba(true);
Shinya Kitaoka 120a6e
  fmt.setDepthBufferSize(24);
Shinya Kitaoka 120a6e
  fmt.setDepth(true);
Shinya Kitaoka 120a6e
  fmt.setStencilBufferSize(8);
Shinya Kitaoka 120a6e
  fmt.setStencil(true);
Shinya Kitaoka 120a6e
  fmt.setAccum(false);
Shinya Kitaoka 120a6e
  fmt.setPlane(0);
Campbell Barton d869b5
#elif defined(LINUX)
Campbell Barton 301bdb
  fmt.setAlphaBufferSize(1);
Campbell Barton 301bdb
  fmt.setAlpha(false);
Campbell Barton 301bdb
  fmt.setRgba(true);
Campbell Barton 301bdb
  fmt.setDepthBufferSize(24);
Campbell Barton 301bdb
  fmt.setDepth(true);
Campbell Barton 301bdb
  fmt.setStencilBufferSize(8);
Campbell Barton 301bdb
  fmt.setStencil(true);
Campbell Barton 301bdb
  fmt.setAccum(false);
Campbell Barton 301bdb
  fmt.setPlane(0);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Il PixelBuffer deve essere con width ed height potenze di 2
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int sizeMax = std::max(rasterSize.lx, rasterSize.ly);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // trovo la potenza di 2 che "contiene" sizeMax e la utilizzo per il PBuffer
Shinya Kitaoka 120a6e
  int pBufferSize = 2;
Shinya Kitaoka 120a6e
  while (pBufferSize < sizeMax) pBufferSize *= 2;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_context =
Shinya Kitaoka 120a6e
      std::make_shared<qglpixelbuffer>(QSize(pBufferSize, pBufferSize), fmt);</qglpixelbuffer>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGLPBuffer::makeCurrent() {
Shinya Kitaoka 120a6e
  if (m_context) {
Shinya Kitaoka 120a6e
    m_context->makeCurrent();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGLPBuffer::doneCurrent() {
Shinya Kitaoka 120a6e
  if (m_context) m_context->doneCurrent();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void QtOfflineGLPBuffer::getRaster(TRaster32P raster) {
Shinya Kitaoka 120a6e
  makeCurrent();
Shinya Kitaoka 120a6e
  glFlush();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // The image is stored using a 32-bit ARGB format (0xAARRGGBB).
Shinya Kitaoka 120a6e
  QImage image = m_context->toImage();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int lx = raster->getLx(), ly = raster->getLy();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static const TRaster32P emptyRaster;
Shinya Kitaoka 120a6e
  if (image.height() == 0 || image.width() == 0) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // devo iniziare a leggere la Y da un certo offset
Shinya Kitaoka 120a6e
  // dato dalla differenza tra la y della image e la y del raster
Shinya Kitaoka 120a6e
  int yOffset = image.height() - ly;
Shinya Kitaoka 120a6e
  raster->lock();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  for (int y = 0; y < ly; y++) {
Shinya Kitaoka 120a6e
    QRgb *inpPix = (QRgb *)image.scanLine(yOffset + y);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TPixel32 *pix    = raster->pixels(ly - 1 - y);
Shinya Kitaoka 120a6e
    TPixel32 *endPix = pix + lx;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    for (; pix < endPix; ++pix) {
Shinya Kitaoka 120a6e
      pix->m = 255;
Shinya Kitaoka 120a6e
      pix->r = qRed(*inpPix);
Shinya Kitaoka 120a6e
      pix->g = qGreen(*inpPix);
Shinya Kitaoka 120a6e
      pix->b = qBlue(*inpPix);
Shinya Kitaoka 120a6e
      inpPix++;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  raster->unlock();
Toshihiro Shimizu 890ddd
}