📄 image_buffer.c
字号:
/*** Source file for blobdetect. (c) 2004 Per-Erik Forssen**** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.** ** See the file COPYING for details.***/#include <stdio.h>#include <stdlib.h>#include "image_buffer.h"buffer *buffer_new(int r,int c,int nd) {buffer *bf; fpnum *darr; bf=(buffer *)calloc(1,sizeof(buffer)); darr=(fpnum *)calloc(r*c*nd,sizeof(fpnum)); bf->rows=r; bf->cols=c; bf->ndim=nd; bf->data=darr; return(bf);}/* Version which does not allocate data buffer */buffer *buffer_new0(fpnum *darr,int r,int c,int nd) {buffer *bf; bf=(buffer *)calloc(1,sizeof(buffer)); bf->rows=r; bf->cols=c; bf->ndim=nd; bf->data=darr; return(bf);}/* Make an identical copy of a buffer */buffer *buffer_clone(buffer *bf) {int x,y,k;int rows,cols,ndim,cind;buffer *bf_new;fpnum *new_data,*data; rows=bf->rows; cols=bf->cols; ndim=bf->ndim; data=bf->data; /* Allocate new buffer */ bf_new=buffer_new(rows,cols,ndim); new_data=bf_new->data; /* Copy buffer, element by element */ for(x=0;x<cols;x++) { for(y=0;y<rows;y++) { for(k=0;k<ndim;k++) { cind=x*rows+y+k*rows*cols; new_data[cind]=data[cind]; } } } return(bf_new);}void buffer_pdims(buffer *bf) { printf("Buffer: %dx%dx%d\n",bf->rows,bf->cols,bf->ndim);}void buffer_free(buffer *bf) { free(bf->data); free(bf);}ibuffer *ibuffer_new(int r,int c,int nd) {ibuffer *bf; int *darr; bf=(ibuffer *)calloc(1,sizeof(ibuffer)); darr=(int *)calloc(r*c*nd,sizeof(int)); bf->rows=r; bf->cols=c; bf->ndim=nd; bf->data=darr; return(bf);}/* Version which does not allocate data buffer */ibuffer *ibuffer_new0(int *darr,int r,int c,int nd) {ibuffer *bf; bf=(ibuffer *)calloc(1,sizeof(ibuffer)); bf->rows=r; bf->cols=c; bf->ndim=nd; bf->data=darr; return(bf);}void ibuffer_pdims(ibuffer *bf) { printf("iBuffer: %dx%dx%d\n",bf->rows,bf->cols,bf->ndim);}void ibuffer_free(ibuffer *bf) { free(bf->data); free(bf);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -