Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qimage
    Log in to post
    • All categories
    • Perdrix

      Unsolved Building a Pixmap
      General and Desktop • qimage • • Perdrix

      7
      0
      Votes
      7
      Posts
      161
      Views

      SGaist

      Rather than going pixel by pixel, I would write a method that fills a memory block with the content of the vectors.

    • Wenchi

      Unsolved Crash in function: QImageData * QImageData::create(const QSize &size, QImage::Format format)
      General and Desktop • crash qimage bug • • Wenchi

      15
      0
      Votes
      15
      Posts
      406
      Views

      JonB

      @Wenchi said in Crash in function: QImageData * QImageData::create(const QSize &size, QImage::Format format):

      Although the code is crashing in various places, but the crash point is always the same:

      But that is likely --- or just as possible --- indicating you have a problem elsewhere which only shows up here, such as corrupted/misallocated memory? How else would you explain it "crashing" in e.g. QList<MyWidget>.push_back()?

      by the way, I'm fired. ready to get a new start

      I am sorry to hear that, good luck for future.

    • SMEasy

      Solved QPrintPreviewDialog Image is not shown/Bild wird nicht gezeigt
      German • qprintpreviewdi qimage qpaint qprinter • • SMEasy

      3
      0
      Votes
      3
      Posts
      220
      Views

      SMEasy

      @A-A-SEZEN Thanks, it actually works now

    • N

      Solved Issues with loadFromData function in QImage
      General and Desktop • qimage qpixmap taglib image issue • • Nick Redwill

      14
      0
      Votes
      14
      Posts
      547
      Views

      Christian Ehrlicher

      @Nick-Redwill This is what windeployqt is for...

    • D

      Solved Qt 6 fails to load jpg in to QImage
      Qt 6 • qimage • • Dariusz

      6
      0
      Votes
      6
      Posts
      409
      Views

      JKSH

      @Dariusz said in Qt 6 fails to load jpg in to QImage:

      Do you know whats the name of plugin or dll?

      imageformats\qjpeg.dll

    • P

      Solved Blurry and strange color when creating barcode using fonts
      General and Desktop • barcode qimage font qt5.15.2 • • Proton Phoenix

      13
      0
      Votes
      13
      Posts
      335
      Views

      P

      @artwaw said in Blurry and strange color when creating barcode using fonts:

      @Proton-Phoenix I no longer have access to the Zebra I was using in the past (I changed the company since then).
      Zebra printers are a story on their own to troubleshoot anyway...

      General approach I used:

      make sure the printer is configured properly in the system, with the default page size set to the target page size. query the QPrinterInfo instance for the default page size. use that data with QPdfWriter to render whatever text + barcode I need. remember DPI settings, either set what the manual for the printer says (ideal) or 300 (this didn't end well for Dymo printers I used for a while, needed exact DPI of 204 ;) ). print and enjoy.

      In general getting this to work might be lots of trial and error, depending on the brand and drivers. But once it's done right it is literally zero maintenance for years.

      <3 Thank you bro for everything <3

    • S

      Unsolved Modify an image based on slider position PyQT5
      QML and Qt Quick • pyqt5 desktop slider image qimage • • sh-r

      5
      0
      Votes
      5
      Posts
      309
      Views

      SGaist

      Did you consider using the QtGraphicalEffects module ?

    • T

      Unsolved “qimage out of memory returning null image” after working for 60 QImages
      3rd Party Software • opencv qimage qpixmap • • tim5

      5
      0
      Votes
      5
      Posts
      435
      Views

      SGaist

      Hi,

      You should check your video file, but as I wild guess, it's likely a FullHD video which is 1920 * 1024. Since you are creating a RGB QImage out of it, it's already weighing about 6MB per image. QPixmap is meant to be optimised for rendering and thus the backing memory used might even be larger for, for example, alpha channel handling. Depending on what else you do with your application and these images you can pretty quickly hit memory limits if your application is 32bit.

    • C

      Unsolved Bad paint performance on QImage with transparency
      General and Desktop • qopenglwidget qpainter qimage • • closer_ex

      10
      0
      Votes
      10
      Posts
      485
      Views

      SGaist

      One of the issue here is that the conversion must be done each time the draw method is called. If you know that your images will not change or not much then you should do the conversion upfront so that the painting can be optimized.

    • E

      Solved QImage::Format_Invalid from MedaiPlayer QVideoFrames
      General and Desktop • filters qml mediaplayer qimage • • Einstein

      6
      0
      Votes
      6
      Posts
      375
      Views

      SGaist

      Which examples are you referring to ?

    • S

      Unsolved Displaying an image based on Mono10 (Y10P) 10-bit Monochrome lsb Packed data
      General and Desktop • qimage image display • • szumial

      2
      0
      Votes
      2
      Posts
      278
      Views

      SGaist

      Hi,

      The most "simple" is to downsample from 10 to 8 bit.

      Maybe OpenCV has better support for that kind of format and might be an alternative.

    • C

      Unsolved Cannot create QImage using smart pointers
      General and Desktop • qimage qpointer • • chessking5544

      16
      0
      Votes
      16
      Posts
      712
      Views

      S

      @chessking5544 said in Cannot create QImage using smart pointers:

      Will c++ smart pointers work, or is there just no way to do this?

      Just for completeness I will answer this. But first I have to agree with the others that you should allocate QImage on the stack. Good C++ style avoids pointers wherever possible. The best lifetime management is variables on the stack. Containers - and in this case I will count QImage as a container - will internally allocate memory on the heap. This is a good thing as your stack is quite small. I don't know C# well (but assume it has some similarity to Java within this respect), but objects do not need to be allocated using new in C++. If you want polymorphism you can use references instead of pointers. Rarely do you actually need pointers in C++.

      Now to the answer: C++ smart pointers work with every class. Just use it like this:

      std::shared_ptr<QImage> image = std::make_shared<QImage>(QSize(1920,1080), QImage::Format_RGB32);

      Note the use of make_shared here. This will automatically handle out-of-memory errors. Internally it will call new and hand down its parameters to the constructor of QImage. It is advised to use make_shared<QImage>(...) over shared_ptr<QImage>(new QImage(...)) (I can't remember all the reasons).

    • F

      Solved QImage::setAlphaChannel -- obsolete or not?
      General and Desktop • qimage c++ obsolete alphachannel • • FeRDNYC

      3
      0
      Votes
      3
      Posts
      502
      Views

      F

      @Christian-Ehrlicher Aha! Thanks, good to know. I guess that explains this, then:

      >>> from PyQt5 import QtCore, QtGui >>> i = QtGui.QImage("/tmp/front3.jpg") >>> m = QtGui.QImage("/tmp/mask.png") >>> m = m.convertToFormat(QtGui.QImage.Format_Alpha8) >>> i.setAlphaChannel(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'QImage' object has no attribute 'setAlphaChannel' >>> QtCore.PYQT_VERSION_STR '5.14.2' >>> QtCore.QT_VERSION_STR '5.14.2'

      Ooh. Then again, maybe not. Looks like Riverbank didn't get a memo. (After installing from the latest wheels...):

      >>> from PyQt5 import QtCore, QtGui >>> i = QtGui.QImage("/tmp/front3.jpg") >>> m = QtGui.QImage("/tmp/mask.png") >>> m = m.convertToFormat(QtGui.QImage.Format_Alpha8) >>> i.setAlphaChannel(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'QImage' object has no attribute 'setAlphaChannel' >>> QtCore.QT_VERSION_STR '5.15.2' >>> QtCore.PYQT_VERSION_STR '5.15.2'

      Welp, I've got a bug report to file. Thanks for the help!

    • A

      Solved Dump QImage raw pixel data into `std::vector<char>`
      General and Desktop • qimage vector • • abmyii

      47
      0
      Votes
      47
      Posts
      2160
      Views

      A

      Going to mark this thread as closed since it seems the issue lies with VNC, not Qt. Thank you all for your suggestions and helping me to isolate the problem.

      @Christian-Ehrlicher Sorry for stressing you out - I thought you were referring to a specific function for some reason. I really need to slow down when reading and comprehend rather than just having a quick look and then replying which is causing confusion on all sides. Thank you again for your patience and assistance throughout.

    • CJha

      Unsolved Does QPainter tries to paint anything outside the size of paint device?
      General and Desktop • qpainter qimage • • CJha

      2
      0
      Votes
      2
      Posts
      186
      Views

      Kent-Dorfman

      so write a test program, meter the performance of canvas writes vs out-of-bounds writes, and report back.

    • CJha

      Unsolved QPainter: QImage vs QPixmap
      General and Desktop • qpainter qimage qpixmap • • CJha

      7
      0
      Votes
      7
      Posts
      2139
      Views

      artwaw

      Just let Qt do its work. If by drawing directly on QWidget you mean subclassing it and rewriting its Paint() method - don't do it unless you absolutely have to. Or, when you need to provide a delegate for a view.
      So far I've not had the necessity to dive that deep.
      And since you can display (and scale) images and videos using QLabel, push buttons can be readily supplied with an icon... I just had not need.
      Then again, your needs might differ.

    • G

      Unsolved QImage to byte array doesn't work
      General and Desktop • qimage image bytearray epd esp8266 • • Gh0stShell

      5
      0
      Votes
      5
      Posts
      859
      Views

      B

      QImage::save() doesn't get the raw bytes of the image, it converts the image to a file format.
      If you really want the raw bytes, do something like

      QByteArray ba((const char *)preview.constBits(), preview.byteCount());
    • M

      Unsolved QT QImage Read From Error
      General and Desktop • qimage qthread signals & slots qfileinfo • • mvsri

      23
      0
      Votes
      23
      Posts
      769
      Views

      JonB

      @mvsri said in QT QImage Read From Error:

      image_path is nothing but a QString which stores the path to a bmp image in a folder. the path is static it doesn't change.

      I know that! My question is about the content of that file.

      I don't know whether the image writing is finished or not. that's why i used QFile exists to check if the file is created or not and read the image if the path exists.

      But that doesn't tell you anything about whether it has started but not finished writing to that file, does it? (Unless you are relying on Windows or something not allowing a file to satisfy "exists" until it has been closed, which I would see as dodgy in the extreme.) In which case, you will read in an incomplete image file, maybe that's why you have "black" at the bottom? At least put in a qDebug() << image.sizeInBytes() after loading it (though I'm not sure if that's reliable)....

      QFile::remove(image_path);

      It gets worse! This, or renaming: how do you know that at the instant you execute this the camera has not re-started writing to that file for the next capture, and you are (trying to) removing/renaming a file while it is being written anew?

      Is your camera-image-capture-write-to-file a separate process from your code? How do you know when the capture has started/finished writing to the file?

    • I

      Solved Live camera image using OpenCV showing in Qlabel crashes due to out of memory error
      General and Desktop • c++ qt gui opencv qimage qpixmap • • Imran Hassan

      9
      1
      Votes
      9
      Posts
      1154
      Views

      I

      Thank you all guys. Your suggestions and expert opinion helped a lot with solving the problem. QT forum is always so helpful.

      After trying many things here is the conclusion and code is now working perfectly fine

      I removed the tic toc part

      time(&start);
      timer = double(getTickCount());
      tic();
      It was working but crashing then just to make sure that QImage is not NULL I removed the img = QImage(); // releasing memory

      with

      if(!img.isNull())
      img = QImage();
      Its working perfectly fine now.

    • R

      Solved Save QImage from BYTE buffer segfaults ?
      General and Desktop • qimage bmp bytes • • R-P-H

      43
      0
      Votes
      43
      Posts
      4054
      Views

      R

      @mranger90 said in Save QImage from BYTE buffer segfaults ?:

      try:
      BYTE *buf = new BYTE[imWidth * imHeight];

      So the issue turned out to be with the device itself. Changing the code as above and replacing the device solved the issue. Thanks.