Author Topic: Problem trying to paint a QPixmap  (Read 3258 times)

mteira

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • http://zports.sourceforge.net
Problem trying to paint a QPixmap
« on: March 26, 2004, 05:45:06 am »
Hello.
My problem arise when I try to rotate (using a QMatrix), a Pixmap. I\'ve tried both the bitblt function and the QPainter::drawPixmap method (with a QPainter instantiated from my widget).
So, the problem is that the pixmap, when rotated, is always missing some of its parts (on the screen). I dumped the pixmaps to a file, and they looks good. So, it seems related with the drawing routine.
It seems also related with the AtiCore acceleration routines integrated in the libqte shipped with my Sharp SL C760. I\'ve tried the same examples with:
1.-libOpie. It works fine (but slow).
2.-Using the -qws flag on my program. It works fine. But I\'ve seen that, in this way, none of the AtiCore routines are called (I put gdb breakpoints on AtiCore* and no call to them was detected).

I\'m attaching here my (little) program, to see if you can find any mistake on it. Do you know any active support from Sharp? Is there any mailing list where I could post this problem, and expect Sharp/Qt people to look it?

The program needs to be launched with an argument. It must be a file path with a supported image file into it.
The program generates 4 rotated QPixmaps from the original QImage loaded from the file. Them, it tryes to paint it on screen as fast as possible using a QTimer.

You need to generate a Makefile with the tmake utility.

Thanks.


MyWidget.h
====================================
#include <qpixmap.h>
#include <qimage.h>
#include <qwidget.h>
#include <qwmatrix.h>
                                                                               
class MyWidget_t: public QWidget {
  Q_OBJECT;
public:
  MyWidget_t ( const char *fNameIn,
               QWidget* parent = 0,
               const char* name = 0);
  int framecount () const { return m_framecount; }
  bool closed () const { return m_closed; }
public slots:
void blit ();
protected:
  virtual void closeEvent (QCloseEvent*);
private:
  const char *fName;
  bool m_closed;
  int m_framecount;
  QImage  m_solidimg;
  QPixmap m_solidpix[4];
};
===================================
main.cc
===================================
#include <stdio.h>
#include <unistd.h>
#include <iostream>
                                                                               
                                                                               
#include <time.h>
                                                                               
#include <qpe/qpeapplication.h>
#include <qpainter.h>
#include <qtimer.h>
                                                                               
#include \"MyWidget.h\"
                                                                               
using namespace std;
                                                                               
MyWidget_t::MyWidget_t( const char *fNameIn,
                        QWidget* parent,
                        const char* name):
  QWidget (parent, name),
  m_closed (false),
  m_framecount (0)
                                                                               
{
  fName = fNameIn;
  QWMatrix m;
  m_solidimg.load( fName );
  m_solidpix[0].convertFromImage (m_solidimg);
  m.rotate(90);
  m_solidpix[1] = m_solidpix[0].xForm( m );
  m.rotate(90);
  m_solidpix[2] = m_solidpix[0].xForm( m );
  m.rotate(90);
  m_solidpix[3] = m_solidpix[0].xForm( m );
 
  QTimer *t = new QTimer (this);
  connect (t, SIGNAL (timeout ()),
           SLOT (blit ()));
  t->start (0, FALSE);
}
 
void
MyWidget_t::closeEvent (QCloseEvent* e)
{
  e->accept ();
  m_closed = (1==1);
}
void
MyWidget_t::blit ()
{
  QPainter p( this );
  //Clean up the widget in blue
  p.fillRect( 0, 0,
              size().width(),
              size().height(),
              backgroundColor() );
 
  p.drawPixmap (0, 0, m_solidpix[ m_framecount % 4 ] );
  m_framecount++;
}
 
int
main (int argc, char* argv[])
{
  QPEApplication a (argc, argv);
  //  QPixmap::setDefaultOptimization( QPixmap::BestOptim );
  MyWidget_t mainWin( argv[1] );
  mainWin.show();
  a.setMainWidget (&mainWin);
  time_t t1;
  time (&t1);
  int retval = a.exec ();
  time_t t2;
  time (&t2);
  double fps = mainWin.framecount () / double (t2 - t1);
  cerr << fps << \" fpsn\";
  return retval;
}
=======================================
blit.pro
=======================================
TEMPLATE        = app
CONFIG         += qtopia warn_on debug
HEADERS         = MyWidget.h
SOURCES         = main.cc
TARGET          = blitter
DESTDIR         = bin
INCLUDEPATH += $(QTDIR)/include
DEPENDPATH      += $(QTDIR)/include
LIBS           += -lqpe
VERSION         = 0.0.1
========================================

mteira

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • http://zports.sourceforge.net
Problem trying to paint a QPixmap
« Reply #1 on: June 24, 2004, 03:57:14 am »
I see that the last post is from Myckeyl, but I'm not able to read it. Myckeyl, could you please repost your answer? I'm impatient. ;-)

Perhaps some little leak on the forum migration, but some threads are notifying more posts than they really show.

Regards.

Mickeyl

  • Hero Member
  • *****
  • Posts: 1495
    • View Profile
    • http://www.Vanille.de
Problem trying to paint a QPixmap
« Reply #2 on: June 24, 2004, 06:00:52 am »
I wrote that I saw this earlier and we pinned it down to be a bug in the W100 accelleration of Sharp's version of Qt/Embedded. Unfortunately there's nothing we can do about it since it's closed source.
Cheers,

Michael 'Mickey' Lauer | Embedded Linux Freelancer | www.Vanille-Media.de
Consider donating, if you like the software I contribute to.

mteira

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • http://zports.sourceforge.net
Problem trying to paint a QPixmap
« Reply #3 on: June 24, 2004, 07:26:58 am »
Remembering, I think that I asked you in the irc channel some months ago about this same problem.

Well, all this, as you posibly remember, was focused to get 2D acceleration on the libSDL.

Perhaps could be possible to add 2D acceleration to Opie. It's the next step we could try, I've seen that somebody has made some work using the linux imageon chip driver at:
http://www.mnementh.co.uk/docs/imageon/

also, the author(s) says that all this work is based in the GPL linux driver. So, I suppose it could be used in Opie with no license problem.

Implementing in libSDL direct calls to the hardware to get acceleration is not possible, because I've got conflicts between libSDL and QTopia. We'll need an opie accelerated version, I think.

I also remember that you talked me about some effort to get the code from imageon driver free. Any move on that direction?

Regards.

Mickeyl

  • Hero Member
  • *****
  • Posts: 1495
    • View Profile
    • http://www.Vanille.de
Problem trying to paint a QPixmap
« Reply #4 on: June 24, 2004, 10:19:24 am »
We would definitly like to see W100 accelleration in Opie's version of Qt/Embedded. It's just pending someone to do it. The Opie team has no resources to look into that.
Cheers,

Michael 'Mickey' Lauer | Embedded Linux Freelancer | www.Vanille-Media.de
Consider donating, if you like the software I contribute to.