简体   繁体   中英

How can I convert char* buffer to unsigned char buffer

I have got this code to save image from buffer:

   FILE * fout;      
  fopen_s(&fout, "output.jpg", "wb");
  fwrite(pictureFrame->picture().data(), pictureFrame->picture().size(), 1, fout);

In this way I save cover art using taglib. The "pictureFrame->picture().data()" is char* buffer;

I've just tried to display cover art in gtk+ window. But I've recieved error - argument of type char* is incompatible with parameter of type "const guchar*".

I know, I have to convert char* buffer to unsigned char buffer, but I don't know how. Can anybody help me?

pixbuf_loader = gdk_pixbuf_loader_new ();
gdk_pixbuf_loader_write (pixbuf_loader, pictureFrame->picture().data(), pictureFrame->picture().size(), NULL);

Link to gdk_pixbuf_loader documentation

When you're down in the dirt, you just have to get dirty! Something like (yuk!):

fwrite(reinterpret_cast<unsigned char*>(pictureFrame->picture().data()), pictureFrame->picture().size(), 1, fout);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM