I think there is nothing betterCodeMore clearly. Click "Cuihua, upload code ".
Int videopublisher_t: publishvideo (long LW, long LH, ace_uint8 * dibdata, Long SIZE)
{
Ace_uint8 * jpgimagedata = 0;
Long jpgimagedatasize = 0;
Cximage image;
Video: framedatawriter_var DW =
Video: framedatawriter: _ narrow (this-> datawriter _. In ());
If (CORBA: is_nil (DW. In ()))
{
Ace_error_return (lm_error, "(% T | % t) narrow frame data writer/N"),-1 );
}
// Bytes alignment
Ace_uint32 bytesperline = 4 * (LW * 24 + 31)/32 );
// Convert original RGB data to image
Image. createfromarray (
(Unsigned char *) dibdata,
Lw,
LH,
24,
Bytesperline,
False );
Image. encode (jpgimagedata, jpgimagedatasize, cximage_format_jpg );
Image. set0000quality (24 );
Video: frame;
Frame. frameid = 0;
Frame. timestamp =: gettimestamp ();
Frame. DeviceID = options: instance ()-> getdeviceid ();
Frame. type = video: it_jpg;
Frame. deviceinfo = CORBA: string_dup (this-> statmsg _);
Frame. image. Length (jpgimagedatasize );
Ace_ OS: memcpy (frame. image. get_buffer (), (const void *) jpgimagedata, jpgimagedatasize );
Image. freememory (jpgimagedata );
Dds: returncode_t ret = DW-> write (frame, DDS: handle_nil );
If (Ret! = Dds: retcode_ OK)
{
Ace_error_return (lm_error, "(% T | % t) Data writer/N"),-1 );
}
return 0;
}