×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    93

    QImage::scaleWidth: Image is a null image

    Hi,
    I'm trying to load in a QListWidget a list of all the images present in the phone, actually i'm able to find all the images, but when I try to load the icons, i'm able to do that only for the first five items:

    Here is my code:

    for (int i=0;i<imagesFileList->size();i++)
    {
    qDebug()<<"FILE "<<imagesFileList->at(i);

    image = new QImage(imagesFileList->at(i));
    newImage = image->scaledToWidth(32);
    qDebug()<<newImage.size().width();
    QIcon icon(QPixmap::fromImage((newImage)));
    QListWidgetItem *item = new QListWidgetItem(icon,imagesFileList->at(i));
    ui->listWidget->addItem(item);


    #ifdef Q_OS_SYMBIAN
    TInt mem, size, limit;
    User::Heap().AllocSize(mem); // Amount allocated
    size = User::Heap().Size(); // Current heap size
    limit = User::Heap().MaxLength(); // Max heap size

    qDebug()<<"MEM"<<mem;
    qDebug()<<"size"<<size;
    qDebug()<<"limit"<<limit;
    #endif
    }

    and this is the output in the prompt:

    [Qt Message] MEM 12874132
    [Qt Message] size 13012872
    [Qt Message] limit 23068672
    [Qt Message] FILE "E:/Images/12.JPG"
    [Qt Message] 32
    [Qt Message] MEM 16563832
    [Qt Message] size 16699272
    [Qt Message] limit 23068672
    [Qt Message] FILE "E:/Images/13.JPG"
    [Qt Message] 32
    [Qt Message] MEM 20253140
    [Qt Message] size 20385672
    [Qt Message] limit 23068672
    [Qt Message] FILE "E:/Images/14.JPG"
    [Qt Message] QImage::scaleWidth: Image is a null image

    How can i free heap memory??
    Tnx
    Max

  2. #2
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    93

    Re: QImage::scaleWidth: Image is a null image

    Hi,
    i solved it using a QImageReader and setting the image size to the iconSize, so i'm able to load the images without wasting heap memory

    Max


    Quote Originally Posted by marsiliano View Post
    Hi,
    I'm trying to load in a QListWidget a list of all the images present in the phone, actually i'm able to find all the images, but when I try to load the icons, i'm able to do that only for the first five items:

    Here is my code:

    for (int i=0;i<imagesFileList->size();i++)
    {
    qDebug()<<"FILE "<<imagesFileList->at(i);

    image = new QImage(imagesFileList->at(i));
    newImage = image->scaledToWidth(32);
    qDebug()<<newImage.size().width();
    QIcon icon(QPixmap::fromImage((newImage)));
    QListWidgetItem *item = new QListWidgetItem(icon,imagesFileList->at(i));
    ui->listWidget->addItem(item);


    #ifdef Q_OS_SYMBIAN
    TInt mem, size, limit;
    User::Heap().AllocSize(mem); // Amount allocated
    size = User::Heap().Size(); // Current heap size
    limit = User::Heap().MaxLength(); // Max heap size

    qDebug()<<"MEM"<<mem;
    qDebug()<<"size"<<size;
    qDebug()<<"limit"<<limit;
    #endif
    }

    and this is the output in the prompt:

    [Qt Message] MEM 12874132
    [Qt Message] size 13012872
    [Qt Message] limit 23068672
    [Qt Message] FILE "E:/Images/12.JPG"
    [Qt Message] 32
    [Qt Message] MEM 16563832
    [Qt Message] size 16699272
    [Qt Message] limit 23068672
    [Qt Message] FILE "E:/Images/13.JPG"
    [Qt Message] 32
    [Qt Message] MEM 20253140
    [Qt Message] size 20385672
    [Qt Message] limit 23068672
    [Qt Message] FILE "E:/Images/14.JPG"
    [Qt Message] QImage::scaleWidth: Image is a null image

    How can i free heap memory??
    Tnx
    Max

Similar Threads

  1. Null image Problem
    By mihirpalkhiwala in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2010-09-07, 06:18
  2. Null pointer when load image.
    By i4ba1 in forum Mobile Java General
    Replies: 2
    Last Post: 2010-08-16, 09:42
  3. Drawing Lines on an Image (image graphics object returns null)
    By nicenouman in forum Mobile Java General
    Replies: 4
    Last Post: 2006-09-21, 10:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×