Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, September 1998
Creating pixmaps from a large image


Message 1 in thread

In one of the applications I am currently working on I have an image
file with a whole deck of cards positioned next to eachother. I've
attached the relevant code snippet at the end of this mail. The
problem is that when I bitblt onto a surface, the pixmaps that appear
are not the proper images - the pixmaps consists of triangular
"strips" of different areas of the original image. To illustrate


     111111111111111
     111111111111111
     111111111112222
     111111122222222
     111222222222222
     222222222222222
     222222222222222
     222222222223333
     222222233333333
     222333333333333
     333333333333333

Where the numbers illustrate different parts of the original qimage
object. The parts that are visible from for instance the 1 part are
not skewed in anyway, so it seems it got the width right when creating
the pixmaps, but I can not understand why other parts of the qimage
are pasted in the way they are.

Can anybody tell me what is going on, or tell me the right way to
create a lot of smaller pixmaps from a large composite image? Has
anybody else experienced similar problems?

Thanks in advance,

Marius

bool
DeckOfCards_t::load (const char *filename)
{
	bool retval = m_deck.load (filename);
	if (retval) {
		removeOldPixmaps ();
		int x = 0;
		int y = 0;
		int w = m_deck.width () / 53;
		int h = m_deck.height ();
		for (int i=0; i < 53; i++) {
			QImage img = m_deck.copy (x, y, w, h);
			QPixmap* pix = new QPixmap;
			pix->convertFromImage (img);
			m_card[i] = pix;
			x += w;
		}
	}
	return retval;
}