Changeset 1341 for libcaca/trunk/cucul/frame.c
- Timestamp:
- Nov 11, 2006, 2:29:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/frame.c
r1339 r1341 82 82 /** \brief Add a frame to a canvas. 83 83 * 84 * Create a new frame within the given canvas. Its contents a re copied85 * from the currently active frame.84 * Create a new frame within the given canvas. Its contents and attributes 85 * are copied from the currently active frame. 86 86 * 87 87 * The frame index indicates where the frame should be inserted. Valid … … 100 100 * \return 0 in case of success, -1 if an error occurred. 101 101 */ 102 int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int frame)103 { 104 unsigned int size = cv->width * cv->height * sizeof(uint32_t);102 int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int id) 103 { 104 unsigned int size = cv->width * cv->height; 105 105 unsigned int f; 106 106 107 if( frame> cv->framecount)108 frame= cv->framecount;107 if(id > cv->framecount) 108 id = cv->framecount; 109 109 110 110 cv->framecount++; … … 112 112 sizeof(struct cucul_frame) * cv->framecount); 113 113 114 for(f = cv->framecount - 1; f > frame; f--)114 for(f = cv->framecount - 1; f > id; f--) 115 115 cv->frames[f] = cv->frames[f - 1]; 116 116 117 cv->frames[ frame].width = cv->width;118 cv->frames[ frame].height = cv->height;119 cv->frames[ frame].chars = malloc(size);120 memcpy(cv->frames[ frame].chars, cv->chars, size);121 cv->frames[ frame].attrs = malloc(size);122 memcpy(cv->frames[ frame].attrs, cv->attrs, size);123 cv->frames[ frame].curattr = cv->curattr;124 125 if(cv->frame >= frame)117 cv->frames[id].width = cv->width; 118 cv->frames[id].height = cv->height; 119 cv->frames[id].chars = malloc(size * sizeof(uint32_t)); 120 memcpy(cv->frames[id].chars, cv->chars, size * sizeof(uint32_t)); 121 cv->frames[id].attrs = malloc(size * sizeof(uint32_t)); 122 memcpy(cv->frames[id].attrs, cv->attrs, size * sizeof(uint32_t)); 123 cv->frames[id].curattr = cv->curattr; 124 125 if(cv->frame >= id) 126 126 cv->frame++; 127 127 … … 150 150 * \return 0 in case of success, -1 if an error occurred. 151 151 */ 152 int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int frame)152 int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id) 153 153 { 154 154 unsigned int f; 155 155 156 if( frame>= cv->framecount)156 if(id >= cv->framecount) 157 157 { 158 158 #if defined(HAVE_ERRNO_H) … … 170 170 } 171 171 172 free(cv->frames[ frame].chars);173 free(cv->frames[ frame].attrs);174 175 for(f = frame+ 1; f < cv->framecount; f++)172 free(cv->frames[id].chars); 173 free(cv->frames[id].attrs); 174 175 for(f = id + 1; f < cv->framecount; f++) 176 176 cv->frames[f - 1] = cv->frames[f]; 177 177 … … 180 180 sizeof(struct cucul_frame) * cv->framecount); 181 181 182 if(cv->frame > frame)182 if(cv->frame > id) 183 183 cv->frame--; 184 else if(cv->frame == frame)184 else if(cv->frame == id) 185 185 { 186 186 cv->frame = 0;
Note: See TracChangeset
for help on using the changeset viewer.