[Kde-imaging] how to convert the raw data to Qt image format

Gilles Caulier caulier.gilles at free.fr
Thu Aug 5 09:13:50 CEST 2004


Le lundi 2 Août 2004 07:18, desertstar a écrit :
> Dear everyone:
> 	i am facing with a problem in my program.

What's this exactly ? A video4linux image capture KIPI plugin ?

>         Now,i had used video4linux and ioctl operation to get a picture
> data from the ov511
> USB camera.Then i should display it on the screen with QT.
>         The first problem was i can't make sure the data i got was a
> right image data from
> camera,i do as follow:
> *****************************************************
> .........
>   grab_data =(unsigned char*)mmap(0, grab_size, PROT_READ | PROT_WRITE,
> MAP_SHARED, grab_fd, 0);
>   if ((grab_data == NULL) || (MAP_FAILED == grab_data))
>    printf("couldn't mmap vidcam. your card doesn't support that?\n");
>  t=1;
>  for (int i=0;i<t;i++)
>         if (ioctl(grab_fd, VIDIOCMCAPTURE, &grab_buf) == -1)
>               printf("error when ioctl VIDIOCMCAPTURE");
>  int i=0;
>  if (ioctl(grab_fd, VIDIOCSYNC, &i) == -1)   printf("error ioctl
> VIDIOCSYNC");
> ...........
> **********************************************************
>      does this right?And i still don't understand variable t's
> function,does it need to capture
> the picture many times?

No idea...

> 	The second problem was that if i got the right image data,then how can
> i turn it
> into the right Qimage format?And what the format the Qimage will be?

Typically, video4linuw provide an RGBA raw image format. It's easy to put that 
in a Qimage like this :

    QImage image;
    image.create( w, h, 32 );
    image.setAlphaBuffer(true) ;
    memcpy(image.bits(), data, image.numBytes());

Where data is an uint pointer to the RAW image data @.

Regards

Gilles Caulier

>       Many thanks.
>
>
> _______________________________________________
> Kde-imaging mailing list
> Kde-imaging at kde.org
> https://mail.kde.org/mailman/listinfo/kde-imaging

-- 
Gilles Caulier


More information about the Kde-imaging mailing list