diff options
Diffstat (limited to 'src/kernel/tqimage.cpp')
-rw-r--r-- | src/kernel/tqimage.cpp | 158 |
1 files changed, 10 insertions, 148 deletions
diff --git a/src/kernel/tqimage.cpp b/src/kernel/tqimage.cpp index d31168c70..46002b8f8 100644 --- a/src/kernel/tqimage.cpp +++ b/src/kernel/tqimage.cpp @@ -59,12 +59,8 @@ #include <ctype.h> #include <stdlib.h> -#ifdef TQ_WS_QWS -#include "qgfx_qws.h" -#endif - -// 16bpp images on supported on TQt/Embedded -#if !defined( TQ_WS_QWS ) && !defined(TQT_NO_IMAGE_16_BIT) +// 16bpp images on supported +#if !defined(TQT_NO_IMAGE_16_BIT) #define TQT_NO_IMAGE_16_BIT #endif @@ -143,12 +139,8 @@ *p = tqRgb(255,255,0); \endcode - On TQt/Embedded, scanlines are aligned to the pixel depth and may - be padded to any degree, while on all other platforms, the - scanlines are 32-bit aligned for all depths. The constructor + The scanlines are 32-bit aligned for all depths. The constructor taking a \c{uchar*} argument always expects 32-bit aligned data. - On TQt/Embedded, an additional constructor allows the number of - bytes-per-line to be specified. TQImage supports a variety of methods for getting information about the image, for example, colorTable(), allGray(), isGrayscale(), @@ -510,57 +502,6 @@ TQImage::TQImage( uchar* yourdata, int w, int h, int depth, data->bitordr = bitOrder; } -#ifdef TQ_WS_QWS - -/*! - Constructs an image that uses an existing memory buffer. The - buffer must remain valid for the life of the TQImage. The image - does not delete the buffer at destruction. The buffer is passed as - \a yourdata. The image's width is \a w and its height is \a h. The - color depth is \a depth. \a bpl specifies the number of bytes per - line. - - If \a colortable is 0, a color table sufficient for \a numColors - will be allocated (and destructed later). - - The endianness is specified by \a bitOrder. - - \warning This constructor is only available on TQt/Embedded. -*/ -TQImage::TQImage( uchar* yourdata, int w, int h, int depth, - int bpl, TQRgb* colortable, int numColors, - Endian bitOrder ) -{ - init(); - if ( !yourdata || w <= 0 || h <= 0 || depth <= 0 || numColors < 0 - || INT_MAX / sizeof(uchar *) < uint(h) - || INT_MAX / uint(bpl) < uint(h) - ) - return; // invalid parameter(s) - data->w = w; - data->h = h; - data->d = depth; - data->ncols = numColors; - data->nbytes = bpl * h; - if ( colortable || !numColors ) { - data->ctbl = colortable; - data->ctbl_mine = FALSE; - } else { - // calloc since we realloc, etc. later (ick) - data->ctbl = (TQRgb*)calloc( numColors*sizeof(TQRgb), numColors ); - TQ_CHECK_PTR(data->ctbl); - data->ctbl_mine = TRUE; - } - uchar** jt = (uchar**)malloc(h*sizeof(uchar*)); - TQ_CHECK_PTR(jt); - for (int j=0; j<h; j++) { - jt[j] = yourdata+j*bpl; - } - data->bits = jt; - data->bitordr = bitOrder; -} -#endif // TQ_WS_QWS - /*! Destroys the image and cleans up. */ @@ -666,15 +607,7 @@ TQImage TQImage::copy() const } else { TQImage image; image.create( width(), height(), depth(), numColors(), bitOrder() ); -#ifdef TQ_WS_QWS - // TQt/Embedded can create images with non-default bpl - // make sure we don't crash. - if ( image.numBytes() != numBytes() ) - for ( int i = 0; i < height(); i++ ) - memcpy( image.scanLine(i), scanLine(i), image.bytesPerLine() ); - else -#endif - memcpy( image.bits(), bits(), numBytes() ); + memcpy( image.bits(), bits(), numBytes() ); memcpy( image.colorTable(), colorTable(), numColors() * sizeof(TQRgb) ); image.setAlphaBuffer( hasAlphaBuffer() ); image.data->dpmx = dotsPerMeterX(); @@ -816,7 +749,7 @@ TQImage TQImage::copy(int x, int y, int w, int h, int conversion_flags) const The image depth is the number of bits used to encode a single pixel, also called bits per pixel (bpp) or bit planes of an image. - The supported depths are 1, 8, 16 (TQt/Embedded only) and 32. + The supported depths are 1, 8 and 32. \sa convertDepth() */ @@ -826,8 +759,8 @@ TQImage TQImage::copy(int x, int y, int w, int h, int conversion_flags) const Returns the size of the color table for the image. - Notice that numColors() returns 0 for 16-bpp (TQt/Embedded only) - and 32-bpp images because these images do not use color tables, + Notice that numColors() returns 0 for + 32-bpp images because these images do not use color tables, but instead encode pixel values as RGB triplets. \sa setNumColors() colorTable() @@ -924,9 +857,6 @@ TQImage TQImage::copy(int x, int y, int w, int h, int conversion_flags) const \link ::tqGreen() tqGreen()\endlink and \link ::tqBlue() tqBlue()\endlink, etc. (ntqcolor.h) to access the pixels. - \warning If you are accessing 16-bpp image data, you must handle - endianness yourself. (TQt/Embedded only) - \sa bytesPerLine() bits() jumpTable() */ @@ -1278,15 +1208,9 @@ bool TQImage::create( int width, int height, int depth, int numColors, setNumColors( 0 ); return FALSE; } -// TQt/Embedded doesn't waste memory on unnecessary padding. -#ifdef TQ_WS_QWS - const int bpl = (width*depth+7)/8; // bytes per scanline - const int pad = 0; -#else const int bpl = ((width*depth+31)/32)*4; // bytes per scanline // #### WWA: shouldn't this be (width*depth+7)/8: const int pad = bpl - (width*depth)/8; // pad with zeros -#endif if ( INT_MAX / uint(bpl) < uint(height) || bpl < 0 || INT_MAX / sizeof(uchar *) < uint(height) ) { // sanity check for potential overflow @@ -2115,7 +2039,7 @@ static bool convert_32_to_16( const TQImage *src, TQImage *dst ) Converts the depth (bpp) of the image to \a depth and returns the converted image. The original image is not changed. - The \a depth argument must be 1, 8, 16 (TQt/Embedded only) or 32. + The \a depth argument must be 1, 8 or 32. Returns \c *this if \a depth is equal to the image depth, or a \link isNull() null\endlink image if this image cannot be @@ -2386,7 +2310,7 @@ bool isGray(TQRgb c) (i.e. their red, green and blue components are equal); otherwise returns FALSE. - This function is slow for large 16-bit (TQt/Embedded only) and 32-bit images. + This function is slow for large 32-bit images. \sa isGrayscale() */ @@ -2419,7 +2343,7 @@ bool TQImage::allGray() const } /*! - For 16-bit (TQt/Embedded only) and 32-bit images, this function is + For 32-bit images, this function is equivalent to allGray(). For 8-bpp images, this function returns TRUE if color(i) is @@ -4745,26 +4669,12 @@ bool read_dib( TQDataStream& s, int offset, int startpos, TQImage& image ) d->at( startpos + offset ); // start of image data int bpl = image.bytesPerLine(); -#ifdef TQ_WS_QWS - // - // Guess the number of bytes-per-line if we don't know how much - // image data is in the file (bogus image ?). - // - int bmpbpl = bi.biSizeImage > 0 ? - bi.biSizeImage / bi.biHeight : - (d->size() - offset) / bi.biHeight; - int pad = bmpbpl-bpl; -#endif uchar **line = image.jumpTable(); if ( nbits == 1 ) { // 1 bit BMP image while ( --h >= 0 ) { if ( d->readBlock((char*)line[h],bpl) != bpl ) break; -#ifdef TQ_WS_QWS - if ( pad > 0 ) - d->at(d->at()+pad); -#endif } if ( ncols == 2 && tqGray(image.color(0)) < tqGray(image.color(1)) ) swapPixel01( &image ); // pixel 0 is white! @@ -4911,10 +4821,6 @@ bool read_dib( TQDataStream& s, int offset, int startpos, TQImage& image ) while ( --h >= 0 ) { if ( d->readBlock((char *)line[h],bpl) != bpl ) break; -#ifdef TQ_WS_QWS - if ( pad > 0 ) - d->at(d->at()+pad); -#endif } } } @@ -4989,12 +4895,6 @@ bool qt_write_dib( TQDataStream& s, TQImage image ) } else if ( image.depth() == 32 ) { bpl_bmp = ((image.width()*24+31)/32)*4; nbits = 24; -#ifdef TQ_WS_QWS - } else if ( image.depth() == 1 || image.depth() == 8 ) { - // TQt/E doesn't word align. - bpl_bmp = ((image.width()*image.depth()+31)/32)*4; - nbits = image.depth(); -#endif } else { bpl_bmp = bpl; nbits = image.depth(); @@ -5035,16 +4935,8 @@ bool qt_write_dib( TQDataStream& s, TQImage image ) int y; if ( nbits == 1 || nbits == 8 ) { // direct output -#ifdef TQ_WS_QWS - // TQt/E doesn't word align. - int pad = bpl_bmp - bpl; - char padding[4]; -#endif for ( y=image.height()-1; y>=0; y-- ) { d->writeBlock( (char*)image.scanLine(y), bpl ); -#ifdef TQ_WS_QWS - d->writeBlock( padding, pad ); -#endif } return TRUE; } @@ -6499,33 +6391,3 @@ void TQImage::setText(const char* key, const char* lang, const TQString& s) } #endif // TQT_NO_IMAGE_TEXT - -#ifdef TQ_WS_QWS -/*! - \internal -*/ -TQGfx * TQImage::graphicsContext() -{ - TQGfx * ret=0; - if(depth()) { - int w = qt_screen->mapToDevice( TQSize(width(),height()) ).width(); - int h = qt_screen->mapToDevice( TQSize(width(),height()) ).height(); - ret=TQGfx::createGfx(depth(),bits(),w,h,bytesPerLine()); - } else { - tqDebug("Trying to create image for null depth"); - return 0; - } - if(depth()<=8) { - TQRgb * tmp=colorTable(); - int nc=numColors(); - if(tmp==0) { - static TQRgb table[2] = { tqRgb(255,255,255), tqRgb(0,0,0) }; - tmp=table; - nc=2; - } - ret->setClut(tmp,nc); - } - return ret; -} - -#endif |