I don't understand your question. What exactly do you have trouble with? From your post it seems an image 32bit deep (4 channels (RGBA) 8 bits each) with size of 133x135 is carried.
I don't understand your question. What exactly do you have trouble with? From your post it seems an image 32bit deep (4 channels (RGBA) 8 bits each) with size of 133x135 is carried.
The problem is not the data (thanks for help) the current problem is which datatype I have to use that QDBus sends it in the correct form.
Currently I use a QVariantList and insert all the vaues, in the working notification it looks like I have to send a struct over QDBus but I don't know how.
Here is what I get
Qt Code:
string "icon_data" int32 133 int32 135 int32 532 boolean true int32 8 int32 4 array [ byte 137 byte 80 byte 78 byte 71 ..... ]To copy to clipboard, switch view to plain text mode
and this is what I need:
Qt Code:
array [ dict entry( string "icon_data" variant struct { int32 50 int32 50 int32 200 boolean true int32 8 int32 4 array [ byte 255 byte 32 byte 57 byte 93 byte 255 byte 32 byte 57 byte 93 byte 255 byte 32 ....... ] } ) ]To copy to clipboard, switch view to plain text mode
Ok now I get that far
Qt Code:
array [ dict entry( string "icon_data" variant array [ variant int32 133 variant int32 135 variant int32 532 variant boolean true variant int32 8 variant int32 4 variant array [ byte 137 byte 80 byte 78 byte 71 byte 13 byte 10 .......To copy to clipboard, switch view to plain text mode
at least the beginning seams to be right
but I have no idea how to get the entry struct.
My current code is
but instead of QVariantList for the body i have to use something different, but what?Qt Code:
QVariantMap out; if(img.isNull())return out; int width=img.width(); int height=img.height(); int rowstride=img.bytesPerLine(); bool hasAlpha=img.hasAlphaChannel(); int channels; if(img.isGrayscale()) channels=1; else{ channels =3; if(hasAlpha) channels=4; } int bitsPerSample=img.depth()/channels; QByteArray image; img.save( &buffer, "PNG" ); QVariantList o2; o2<<width<<height<<rowstride<<hasAlpha<<bitsPerSample<<channels<<image; out.insert("icon_data",o2); return out; }To copy to clipboard, switch view to plain text mode
Hi I finally got it to send a image but the image is not displayed correct, so I think there is a bug in my mtheode so here is the code
Qt Code:
if(img.isNull())return; int id=qDBusRegisterMetaType<iiibiiay>(); iiibiiay i; i.width=img.width(); i.height=img.height(); i.rowstride=img.bytesPerLine(); i.hasAlpha=img.hasAlphaChannel(); if(img.isGrayscale()) i.channels=1; else{ i.channels =3; if(i.hasAlpha) i.channels=4; } i.bitsPerSample=img.depth()/i.channels; img.save( &buffer, "PNG" ); } a.beginStructure(); a << i.width<<i.height<<i.rowstride<<i.hasAlpha<<i.bitsPerSample<<i.channels<<i.image; a.endStructure(); return a; } a.beginStructure(); a >> i.width>> i.height>> i.rowstride>> i.hasAlpha>> i.bitsPerSample>> i.channels>> i.image; a.endStructure(); return a; }To copy to clipboard, switch view to plain text mode
The image in the upper left corner and the big rectangel should be the same
Try only sending img.bits() as the image data. If you were to send PNG image will all headers and stuff, all the information about the image wouldn't be necessary because they could be taken from PNG headers.
I'v got even one step closer to my ultimate goal
Qt Code:
for(int ii=0;ii<img.numBytes();++ii) i.image.append(img.pixel(ii%i.width,ii/i.width));To copy to clipboard, switch view to plain text mode
does anybody know how to get a pixbuff out of a QImage without using gdk?
pixbuff is a GDK concept. It's equivalent in Qt is either QImage::bits() or QImage itself. Based on your code I think you should really try QImage::bits()
TheOneRing (23rd November 2009)
Big thanks but I get the wrong color.
Qt Code:
width=img->width(); height=img->height(); rowstride=img->bytesPerLine(); hasAlpha=img->hasAlphaChannel(); channels =img->isGrayscale()?1:hasAlpha?4:3; bitsPerSample=img->depth()/channels; image.append((char*)img->bits(),img->numBytes()); }To copy to clipboard, switch view to plain text mode
Last edited by TheOneRing; 23rd November 2009 at 10:12.
You probably have to swap the order of channels. I would assume - from RGB to BGR, or something like that.
And again big thanks QImage::rgbSwapped() solved the problem
so finally every problem is solved, wysota you are my hero!
Last edited by TheOneRing; 23rd November 2009 at 10:44.
Bookmarks