Ejemplo n.º 1
0
mv_image_t* mv_create_image(mv_size_t size, int depth, int channels)
{
    mv_image_t* img = (mv_image_t *)mv_malloc(sizeof(mv_image_t));
    mv_init_image_header(img, size, depth, channels, IPL_ORIGIN_TL, 4);

    img->imageDataOrigin = (mv_byte*)mv_malloc((size_t)img->imageSize);
    img->imageData = img->imageDataOrigin;

    return img;
}
Ejemplo n.º 2
0
mv_image_t* mv_clone_image(const mv_image_t* src)
{
    assert(src->roi == NULL);

    mv_image_t* dst = (mv_image_t*)mv_malloc(sizeof(mv_image_t));

    memcpy(dst, src, sizeof(mv_image_t));
    dst->imageData = dst->imageDataOrigin = NULL;
    dst->roi = NULL;

    if (src->imageData) {
        int size = src->imageSize;

        dst->imageDataOrigin = (mv_byte*)mv_malloc((size_t)size);
        dst->imageData = dst->imageDataOrigin;
        memcpy(dst->imageData, src->imageData, size);
    }

    return dst;
}
Ejemplo n.º 3
0
mv_image_t* mv_image_cv2mv(IplImage* org)
{
    mv_image_t* image = (mv_image_t*)mv_malloc(sizeof(mv_image_t));

    image->nSize = sizeof(mv_image_t);
    image->ID = org->ID;
    image->nChannels = org->nChannels;    
    image->depth = org->depth;    
    image->dataOrder = org->dataOrder;
    image->origin = org->origin;    
    image->width = org->width;
    image->height = org->height;
    image->roi = NULL;   
    image->imageId = org->imageId;    
    image->imageSize = org->imageSize;    
    image->widthStep = org->widthStep;
    image->imageData = (mv_byte*)mv_malloc(org->imageSize);
    memcpy(image->imageData, org->imageData, org->imageSize);
    image->imageDataOrigin = image->imageDataOrigin;

    return image;
}
Ejemplo n.º 4
0
static void mv_realloc ( ThreadId tid, void* p_new, void* p_old, SizeT new_szB )
{
    if (p_new != p_old)
    {
        mv_free(tid, p_old);
        mv_malloc(tid, p_new, new_szB);
    }
    else
    {
        HP_Chunk        *hc = VG_(HT_lookup)(malloc_list, (UWord)p_old);

        if (!hc)
            return;
   
        if (new_szB > hc->size)
            put_wdata((Addr)p_new + hc->size,
                    MV_ShiftedAlloc, new_szB - hc->size);
        else if (new_szB < hc->size)
            put_wdata((Addr)p_new + new_szB,
                    MV_ShiftedFree, hc->size - new_szB);

        hc->size = new_szB;
    }
}