How to convert QByteArray QImage?

Hello

Anyone know how to convert QByteArray QImage?

You can use this:

QImage img = getAnImage();
QByteArray arr;
QBuffer buf(&arr);
buf.open(QIODevice::WriteOnly);
img.save(&buf, "PNG");
buf.close();

Tags: BlackBerry Developers

Similar Questions

  • Convert QByteArray QImage

    Hi all

    Is it possible to convert QByteArray QImage?

    Answer please!

    See you soon!

    use the registration method.

    example of http://qt-project.org/doc/qt-4.8/qimage.html#save-2

    QImage image;
    QByteArray ba;
    QBuffer buffer(&ba);
    buffer.open(QIODevice::WriteOnly);
    image.save(&buffer, "PNG"); // writes image into ba in PNG format
    
  • Nfc_ndef_record_t convert QByteArray HowTo

    in one of my applications, I use NFC with custom instead of the record to the text file Type to be able to invoke my app since the NFC Tag directly.

    Also, within my application, there is a feature allowing the user to write these Tags NFC

    I would like to use an InvokeActionItem to use the sys. NFCViewer - I love the beautiful UI of it.

    For my text NFC files, it works well.

    Here's the InvokeActionItem:

           InvokeActionItem {
                imageSource: "asset:///images/ic_add.png"
                title: qsTr("NFC Tag Text")
                enabled: nfcActionSelector.selectedValue > 0
                ActionBar.placement: ActionBarPlacement.OnBar
                query {
                    mimeType: "application/vnd.rim.nfc.ndef"
                    invokeTargetId: "sys.NFCViewer"
                    invokeActionId: "bb.action.SHARE"
                }
                handler: InvokeHandler {
                    id: shareHandler
                    onInvoking: {
                        tagWriteAction.data = app.getNdefTextMessage("en", nfcText);
                        shareHandler.confirm();
                    }
                }
            }
    

    This works well using a QByteArray:

    QByteArray ApplicationUI::getNdefTextMessage(const QVariant &lang,
            const QVariant &text) {
        QString ndefLang = lang.toString();
        QString ndefText = text.toString();
        QtMobilitySubset::QNdefRecord ndefRecord = QtMobilitySubset::QNdefRecord();
        int langLength = (ndefLang.length() <= 63) ? ndefLang.length() : 63;
        QByteArray ndefPayload;
        ndefPayload[0] = langLength;
        ndefPayload.append(ndefLang.left(langLength)).append(ndefText.toUtf8());
        ndefRecord.setTypeNameFormat(QtMobilitySubset::QNdefRecord::NfcRtd);
        QByteArray nfcRtdText = "T";
        ndefRecord.setType(nfcRtdText);
        ndefRecord.setPayload(ndefPayload);
        QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage(
                ndefRecord);
        return ndefMessage.toByteArray();
    }
    

    So far so good

    Now, I wanted to implement similar but using a recording of NFC Custom type.

    This application example

    has a method to create a record custom:

    nfc_ndef_record_t* ApplicationUI::makeCustomRecord(QString domain, QString type,
            QString content) {
    
        nfc_ndef_record_t* record = 0;
    
        int textLen = content.length();
        QString domainPlusType = domain.append(":");
        domainPlusType = domainPlusType.append(type);
        int totalLen = textLen;
    
        uchar_t payload[totalLen];
    
        int offset = 0;
        memcpy(&payload[offset], content.toUtf8().constData(), textLen);
    
        CHECK(
                nfc_create_ndef_record(NDEF_TNF_EXTERNAL,
                        domainPlusType.toUtf8().constData(), payload, totalLen, 0,
                        &record));
    
        return record;
    }
    

    Unfortunately, I'm a nfc_ndef_record_t but need a QByteArray, use the same InvokeActionItem way in which regards NFC text documents.

    Who knows how to convert the nfc_ndef_record_t in QByteArray?

    thx for the help

    Thanks to the help John Murray on twitter (@jcmrim) I'm creating a QNdefRecord:

    QByteArray ApplicationUI::makeCustomRecord(QString domain, QString type,
            QString content) {
    
        QString domainPlusType = domain.append(":");
        domainPlusType = domainPlusType.append(type);
    
        QtMobilitySubset::QNdefRecord ndefRecord = QtMobilitySubset::QNdefRecord();
    
        ndefRecord.setTypeNameFormat(QtMobilitySubset::QNdefRecord::ExternalRtd);
        ndefRecord.setType(domainPlusType.toUtf8());
        ndefRecord.setPayload(content.toUtf8());
    
        QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage(
                ndefRecord);
    
        return ndefMessage.toByteArray();
    }
    

    Now the sys. Rises in NFCViewer:

    InvokeActionItem {
                imageSource: "asset:///images/ic_add.png"
                title: qsTr("NFC Custom")
                ActionBar.placement: ActionBarPlacement.OnBar
                query {
                    mimeType: "application/vnd.rim.nfc.ndef"
                    invokeTargetId: "sys.NFCViewer"
                    invokeActionId: "bb.action.SHARE"
                }
                handler: InvokeHandler {
                    id: shareHandler2
                    onInvoking: {
                        tagWriteAction.data = app.makeCustomRecord("org.xxxx", "mytype", nfcText);
                        shareHandler2.confirm();
                    }
                }
            }
    

    But if by tapping a NFC Tag I get

    The data could not be shared over NFC
    

    Any idea?

    Or the NFCViewer not accept ExternalRtd?

    documentation :

    NDEF message is sent in the form of a byte array. The following method is used to create the byte array message:
    

    It works with text documents

    Or I do something wrong to build the payload or the record?

  • How to convert pictures from iPhoto?  I need general info and advice.  My library is huge (95 GB).  I am running OSX El Capitan 10.11.6 on iMac.

    How to convert pictures from iPhoto?  I need general info and advice.  I saw the help info but I am very nervous to take on this project, as my library is huge (95GB), organized in several events and albums.  My library is saved (Time Machine SimpleSave HD).  I am running OSX El Capitan 10.11.6 on iMac.

    Have you seen this document?   Updated Photos for OS X - Apple iPhoto support

    https://support.Apple.com/en-GB/HT204655

    Is your iPhoto Library Library on your system drive in the pictures folder? And you have a lot of free space on your system drive? The migration will need additional temporary storage.

    Then drag the iPhoto library icon pictures open to create a new library of Photos of her.

    Your albums appear unchanged in the Photos.  Events will appear as additional albums, because the pictures has no events.  See this link: How Photos handles content and metadata for iPhoto and Aperture - Apple Support

  • How to convert WAV, Alac

    How to convert WAV to ALAC files.

    1. Select Apple Lossless as your chosen import format using edit > Preferences > import settings.
    2. Choose files to convert.
    3. Use file > convert > create the Version Apple Lossless.

    TT2

  • How to convert .pdf to .epub

    Please see me step by step how to convert .pdf to .epub

    Hello PrasanW.

    Thank you for using communities Support from Apple. I see your message that you want to convert PDF files into ePub files.

    Read this article.

    Creating ePub with Pages files

    Have a great day.

  • How to convert mp3 to acc in new itunes file 12.4?

    How to convert mp3 to acc in new itunes file 12.4?

    Annoydc,

    Read: Re: suddenly I can't right click to create Mp3s in iTunes.

  • How to convert audio files (many voices) to the text?

    Hello community

    How to convert file .aif audio to text?

    It contains several voice

    Thank you

    With a transcription like this service:

    https://www.tech-synergy.com/OtherServices.php

  • How to convert pdf to word

    I was sent an application form which is in pdf format. I clicked on the "edit and response" button that is displayed, but it is said that it is not supported. How to convert the pdf file to a word document so that I can add information to the document?

    There are a number of free PDF converters on the Mac App store, which allows you to convert text files, but I'm not aware of any free programs convert to Word. Besides knowing what looks like an application and how PDF conversion programs work well, I doubt that the results would be good, even if you've spent the money to buy one.

    However, if the file is not protected by, using the forecasting of Apple program, you should be able to fill out the form. Open the file using the preview, select the Tools menu and select annotate. Select the text option. A text box appears with the word TEXT in there you can change it, change the size and color and then move it to the desired location. Once you have done all of the annotations that you fill out the form, you can save it.

  • How to convert Blu Ray Disc of the movie in general video and HD video formats

    How to convert Blu Ray Disc of the movie in general video and HD video formats

    Hello

    I doubt that this is possible because Bluray discs are mostly protected against copying.
    But if you have the Bluray m2ts file on your HARD drive, then you could try the tool called convertXtodvd. But I don't see that the reasons for this
    I mean that you will lose the quality of film converting the blueray to dvd.

  • How to convert an apple store gift card to buy apps for the iphone?

    How to convert an apple store gift card to buy apps for the iphone?

    Try to buy a gift card iTunes Store with her. Apart from that, you can't.

    (140402)

  • need help with my window is in thai and I do not understand to all.how to convert to English?

    need help with my window is in thai and I don't quite understand.
    How to convert to English? I tried for days but still it cannot be changed.
    because I can't read thai... Please help me step by step...

    my pc is touchsmart 9100 windows 7 Professional.

    Not a single word is in English if I go to the "region and language" to change.

    Everthing is in thai in the system.

    Hello

    Where have you bought the PC?

    What is the operating system installed?

    Best regards

    ERICO

  • How to convert a PDF into pages or keynote?

    How to convert a pdf file in preview pages or keynote?

    Download and install Adobe Acrobat Reader from Adobe.com site

    Open the document in Reader, then;   File > save as other > text

  • How to convert wma to mp3 on external hard drive file

    I have a new version of osxe1 mac 10.11.2 capitan how to convert wma files into mp3 files that are on my external hard drive so my mac can copy on my iTunes

    http://www.mediahuman.com/audio-converter/ - free.  Says it does WMA. I have not used it so try at your own risk...

    Switch (free basic version) - http://www.nch.com.au/switch/index.html - I don't know if this will make WMA

    All2Mp3 - http://download.cnet.com/All2MP3/3000-2140_4-190407.html - limited success with WMA

    Flip4mac - need version payware intermediary that allows you to convert.  Use with Quicktime player.  Flip4Mac - http://dynamic.telestream.net/downloads/download-flip4macwmv.asp?prodid=flip4mac wmv - the free version will allow QuickTime play, but not to convert Windows Media files.

    After installation, a new component of Flip4Mac will appear in system preferences.  Make sure that you set the boxes to make sure that it will play WMV files in Quicktime format.

    VLC - not really a converter but will do a bit on the menu export.  Can be slow to be converted and there will be a learning curve.

    Explore online converters when you download a file in a format and download in another.

    I do not know if your computer can run Audion 3 I think I used to use it to convert WMA.

  • How to convert a document pages in macbook air so that when I send to someone directly from my mac, they can open in their computer windows laptop?

    How to convert a document pages in macbook air so that when I send to someone directly from my mac, they can open in their computer windows laptop?

    Depends on. The receiver has Microsoft Word

    If so, open the document, and in the top menu bar, tap Share > Send a copy > Mail > Word > next... and follow the instructions.

    Hope this helps,

    -End

Maybe you are looking for

  • Portege 4000 - Installed W2K - wireless connection problem

    I installed W2K the Portege 4000. XP was too heavy a resource for this system. After you install the network driver wireless Cisco (3.5.13.0) of your Web site, I am unable to get a wireless connection. In XP this comes automatically with an icon. The

  • Customization is lost when I restart Firefox

    Recently, my computer blue-screened and directed a memory dump. Since then, all my customization options seem to have been lost - for example: Firefox not working when I open a new window All my expansion options (each extension home page opens and a

  • Sims 2 installed, but what disk 1 is handed over to play it says bad disc place the correct disc

    OK, so I recently had problems with my hard drive on my laptop Toshiba Satellite A300 and he brought the manufacturer to be replaced. Before the problems, Sims 2 would work with ease, but now after the hard drive has been replaced it will not. It ins

  • How to replace the element in the cluster in a table?

    Hello I understood better choice is to initialize the array first and replace the items in a table instead of insert the new item in a table for example in a while loop. So I started to evaluate since I asked where I want to read a lot of measures fr

  • AMD High Definition Audio Device

    Hello All of a sudden my audio is not plugged in.  My system shows that it is enabled, but there is a red "X" on the bottom right of my screen sound icon. I got it within a week. Product name: HP 15 laptop Product number: F9H60UA #ABA 8.1 Windows 64-