r370: Heroine Virutal's official release 1.2.1
[cinelerra_cv/mob.git] / hvirtual / cinelerra / filetga.C
blobb5901b20c3189a6798fa04dabff79a2d96248200
1 #include "asset.h"
2 #include "edit.h"
3 #include "filetga.h"
4 #include "mwindow.inc"
5 #include "vframe.h"
7 #include <string.h>
8 #include <unistd.h>
10 #include <libintl.h>
11 #define _(String) gettext(String)
12 #define gettext_noop(String) String
13 #define N_(String) gettext_noop (String)
15 /* Known image types. */
16 #define TGA_TYPE_MAPPED      1
17 #define TGA_TYPE_COLOR       2
18 #define TGA_TYPE_GRAY        3
20 /* Only known compression is RLE */
21 #define TGA_COMP_NONE        0 
22 #define TGA_COMP_RLE         1 
25 FileTGA::FileTGA(Asset *asset, File *file)
26  : FileList(asset, file, "TGALIST", ".tga", FILE_TGA, FILE_TGA_LIST)
28         temp = 0;
31 FileTGA::~FileTGA()
33         if(temp) delete temp;
36 int FileTGA::check_sig(Asset *asset)
38 //printf("FileTGA::check_sig 1\n");
39 // Test file extension
40         int result = 0;
41         char *ext = strrchr(asset->path, '.');
42         if(ext)
43         {
44                 if(!strncasecmp(ext, ".tga", 4)) result = 1;
45         }
48 // Test for list
49         if(!result)
50         {
51                 FILE *stream;
52                 if(!(stream = fopen(asset->path, "rb")))
53                 {
54 // file not found
55                         result = 0;
56                 }
57                 else
58                 {
59                         char test[16];
60                         fread(test, 16, 1, stream);
61                         fclose(stream);
62                         if(test[0] == 'T' && test[1] == 'G' && test[2] == 'A' && 
63                                 test[3] == 'L' && test[4] == 'I' && test[5] == 'S' && 
64                                 test[6] == 'T')
65                         {
66                                 result = 1;
67                         }
68                         
69                 }
70         }
71 //printf("FileTGA::check_sig 2\n");
73         return result;
76 void FileTGA::get_parameters(BC_WindowBase *parent_window, 
77                 Asset *asset, 
78                 BC_WindowBase* &format_window,
79                 int audio_options,
80                 int video_options)
82         if(video_options)
83         {
84                 TGAConfigVideo *window = new TGAConfigVideo(parent_window, asset);
85                 format_window = window;
86                 window->create_objects();
87                 window->run_window();
88                 delete window;
89         }
92 #if 0
93 N_("RGB compressed")
94 N_("RGBA compressed")
95 N_("RGB uncompressed")
96 N_("RGBA uncompressed")
97 #endif
99 #define TGA_RGB_RLE "rle "
100 #define TGA_RGBA_RLE "rlea"
101 #define TGA_RGB "raw "
102 #define TGA_RGBA "rawa"
104 #define TGA_RGB_RLE_NAME "RGB compressed"
105 #define TGA_RGBA_RLE_NAME "RGBA compressed"
106 #define TGA_RGB_NAME "RGB uncompressed"
107 #define TGA_RGBA_NAME "RGBA uncompressed"
109 char* FileTGA::compression_to_str(char *compression)
111         if(!strcasecmp(compression, TGA_RGB_RLE)) return _(TGA_RGB_RLE_NAME);
112         if(!strcasecmp(compression, TGA_RGBA_RLE)) return _(TGA_RGBA_RLE_NAME);
113         if(!strcasecmp(compression, TGA_RGB)) return _(TGA_RGB_NAME);
114         if(!strcasecmp(compression, TGA_RGBA)) return _(TGA_RGBA_NAME);
115         return TGA_RGB_NAME;
118 char* FileTGA::str_to_compression(char *string)
120         if(!strcasecmp(compression_to_str(TGA_RGB_RLE), string)) return TGA_RGB_RLE;
121         if(!strcasecmp(compression_to_str(TGA_RGBA_RLE), string)) return TGA_RGBA_RLE;
122         if(!strcasecmp(compression_to_str(TGA_RGB), string)) return TGA_RGB;
123         if(!strcasecmp(compression_to_str(TGA_RGBA), string)) return TGA_RGBA;
124         return TGA_RGB;
127 int FileTGA::can_copy_from(Edit *edit, int64_t position)
129         if(edit->asset->format == FILE_TGA_LIST ||
130                 edit->asset->format == FILE_TGA)
131                 return 1;
132         
133         return 0;
137 int  FileTGA::colormodel_supported(int colormodel)
139         return colormodel;
142 int FileTGA::get_best_colormodel(Asset *asset, int driver)
144         if(!strcasecmp(asset->vcodec, TGA_RGB_RLE) || 
145                 !strcasecmp(asset->vcodec, TGA_RGB)) return BC_RGB888;
146         if(!strcasecmp(asset->vcodec, TGA_RGBA_RLE) ||
147                 !strcasecmp(asset->vcodec, TGA_RGBA)) return BC_RGBA8888;
148         return BC_RGB888;
151 int FileTGA::read_frame(VFrame *frame, VFrame *data)
153         read_tga(asset, frame, data, temp);
154         return 0;
157 int FileTGA::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
159         TGAUnit *tga_unit = (TGAUnit*)unit;
161         write_tga(asset, frame, data, tga_unit->temp);
162         return 0;
165 FrameWriterUnit* FileTGA::new_writer_unit(FrameWriter *writer)
167         return new TGAUnit(this, writer);
170 int FileTGA::get_memory_usage()
172         int result = FileList::get_memory_usage();
173         if(temp) result += temp->get_data_size();
174         return result;
184 #define FOOTERSIZE 26
185 #define HEADERSIZE 18
186 int FileTGA::read_frame_header(char *path)
188         int result = 0;
190 //printf("FileTGA::read_frame_header 1\n");
191         FILE *stream;
193         if(!(stream = fopen(path, "rb")))
194         {
195                 perror("FileTGA::read_frame_header");
196                 return 1;
197         }
199         unsigned char header[HEADERSIZE];
200         fread(header, HEADERSIZE, 1, stream);
201         fclose(stream);
203         asset->width = header[12] | (header[13] << 8);
204         asset->height = header[14] | (header[15] << 8);
205         int bpp = header[16];
206         int rle = header[2] & 0x8;
207         switch(bpp)
208         {
209                 case 32:
210                         if(rle) 
211                                 strcpy(asset->vcodec, TGA_RGBA_RLE);
212                         else
213                                 strcpy(asset->vcodec, TGA_RGBA);
214                         break;
215                 case 24:
216                         if(rle) 
217                                 strcpy(asset->vcodec, TGA_RGB_RLE);
218                         else
219                                 strcpy(asset->vcodec, TGA_RGB);
220                         break;
221         }
222 //printf("FileTGA::read_frame_header 2 %d %d\n", asset->width, asset->height);
224         return result;
227 void FileTGA::read_tga(Asset *asset, VFrame *frame, VFrame *data, VFrame* &temp)
229 // Read header
230         unsigned char *footer, *header;
231         int input_cmodel;
232         int64_t file_offset = 0;
234         footer = data->get_data() + 
235                 data->get_compressed_size() - 
236                 FOOTERSIZE;
237         header = data->get_data();
238         file_offset += HEADERSIZE;
240         int image_type;
241         int image_compression;
242         switch(header[2])
243         {
244                 case 1:
245                         image_type = TGA_TYPE_MAPPED;
246                         image_compression = TGA_COMP_NONE;
247                         break;
248                 case 2:
249                         image_type = TGA_TYPE_COLOR;
250                         image_compression = TGA_COMP_NONE;
251                         break;
252                 case 3:
253                         image_type = TGA_TYPE_GRAY;
254                         image_compression = TGA_COMP_NONE;
255                         break;
256                 case 9:
257                         image_type = TGA_TYPE_MAPPED;
258                         image_compression = TGA_COMP_RLE;
259                         break;
260                 case 10:
261                         image_type = TGA_TYPE_COLOR;
262                         image_compression = TGA_COMP_RLE;
263                         break;
264                 case 11:
265                         image_type = TGA_TYPE_GRAY;
266                         image_compression = TGA_COMP_RLE;
267                         break;
268                 default:
269                         image_type = 0;
270         }
271         
272         int idlength = header[0];
273         int colormaptype = header[1];
274         int colormapindex = header[3] + header[4] * 256;
275         int colormaplength = header[5] + header[6] * 256;
276         int colormapsize = header[7];
277         int xorigin = header[8] + header[9] * 256;
278         int yorigin = header[10] + header[11] * 256;
279         int width = header[12] + header[13] * 256;
280         int height = header[14] + header[15] * 256;
281         int bpp = header[16];
282         int bytes = (bpp + 7) / 8;
283         int alphabits = header[17] & 0x0f;
284         int fliphoriz = (header[17] & 0x10) ? 1 : 0;
285         int flipvert = (header[17] & 0x20) ? 0 : 1;
286         int data_size = data->get_compressed_size();
288         if(idlength) file_offset += idlength;
290 // Get colormap
291         unsigned char *tga_cmap;
292         unsigned char colormap[4 * 256];
294         if(colormaptype == 1)
295         {
296                 int cmap_bytes = (colormapsize + 7) / 8;
297                 tga_cmap = data->get_data() + file_offset;
298                 file_offset += colormaplength * cmap_bytes;
299                 
300                 switch(colormapsize)
301                 {
302                         case 32:
303                                 bgr2rgb(colormap, tga_cmap, colormaplength, cmap_bytes, 1);
304                                 break;
305                         case 24:
306                                 bgr2rgb(colormap, tga_cmap, colormaplength, cmap_bytes, 0);
307                                 break;
308                         case 16:
309                                 upsample(colormap, tga_cmap, colormaplength, cmap_bytes);
310                                 break;
311                 }
312         }
314         int source_cmodel = BC_RGB888;
315         switch(bpp)
316         {
317                 case 32:
318                         source_cmodel = BC_RGBA8888;
319                         break;
320                 case 24:
321                         source_cmodel = BC_RGB888;
322                         break;
323         }
325 // Read image
326         VFrame *output_frame;
327         if(frame->get_color_model() == source_cmodel)
328         {
329                 output_frame = frame;
330         }
331         else
332         {
333                 if(temp && temp->get_color_model() != source_cmodel)
334                 {
335                         delete temp;
336                         temp = 0;
337                 }
338                 
339                 if(!temp)
340                 {
341                         temp = new VFrame(0, width, height, source_cmodel);
342                 }
343                 output_frame = temp;
344         }
346         if(flipvert)
347         {
348                 for(int i = height - 1; i >= 0; i--)
349                 {
350                         read_line(output_frame->get_rows()[i], 
351                                 data->get_data(), 
352                                 file_offset,
353                                 image_type,
354                                 bpp,
355                                 image_compression,
356                                 bytes,
357                                 width,
358                                 fliphoriz,
359                                 alphabits,
360                                 data_size);
361                 }
362         }
363         else
364         {
365                 for(int i = 0; i < height; i++)
366                 {
367                         read_line(output_frame->get_rows()[i], 
368                                 data->get_data(), 
369                                 file_offset,
370                                 image_type,
371                                 bpp,
372                                 image_compression,
373                                 bytes,
374                                 width,
375                                 fliphoriz,
376                                 alphabits,
377                                 data_size);
378                 }
379         }
381         if(output_frame != frame)
382         {
383                 cmodel_transfer(frame->get_rows(), 
384                         output_frame->get_rows(),
385                         frame->get_y(),
386                         frame->get_u(),
387                         frame->get_v(),
388                         output_frame->get_y(),
389                         output_frame->get_u(),
390                         output_frame->get_v(),
391                         0, 
392                         0, 
393                         width, 
394                         height,
395                         0, 
396                         0, 
397                         frame->get_w(), 
398                         frame->get_h(),
399                         output_frame->get_color_model(), 
400                         frame->get_color_model(),
401                         0,
402                         width,
403                         frame->get_w());
404         }
407 void FileTGA::write_tga(Asset *asset, VFrame *frame, VFrame *data, VFrame* &temp)
409         unsigned char header[18];
410         unsigned char footer[26];
411         int64_t file_offset = 0;
412         int out_bpp = 0;
413         int rle = 0;
414         int dest_cmodel = BC_RGB888;
416 //printf("FileTGA::write_tga 1\n");
418         header[0] = 0;
419         header[1] = 0;
420         if(!strcasecmp(asset->vcodec, TGA_RGBA_RLE))
421         {
422                 header[2] = 10;
423         out_bpp = 4;
424                 rle = 1;
425         header[16] = 32; /* bpp */
426         header[17] = 0x28; /* alpha + orientation */
427                 dest_cmodel = BC_RGBA8888;
428         }
429         else
430         if(!strcasecmp(asset->vcodec, TGA_RGBA))
431         {
432                 header[2] = 2;
433         out_bpp = 4;
434                 rle = 0;
435         header[16] = 32; /* bpp */
436         header[17] = 0x28; /* alpha + orientation */
437                 dest_cmodel = BC_RGBA8888;
438         }
439         else
440         if(!strcasecmp(asset->vcodec, TGA_RGB_RLE))
441         {
442                 header[2] = 10;
443         out_bpp = 3;
444                 rle = 1;
445         header[16] = 24; /* bpp */
446         header[17] = 0x20; /* alpha + orientation */
447                 dest_cmodel = BC_RGB888;
448         }
449         else
450         {
451                 header[2] = 2;
452         out_bpp = 3;
453                 rle = 0;
454         header[16] = 24; /* bpp */
455         header[17] = 0x20; /* alpha + orientation */
456                 dest_cmodel = BC_RGB888;
457         }
458     header[3] = header[4] = header[5] = header[6] = header[7] = 0;
459 //printf("FileTGA::write_tga 1\n");
461         VFrame *input_frame;
462         if(frame->get_color_model() == dest_cmodel)
463         {
464                 input_frame = frame;
465         }
466         else
467         {
468                 if(temp && temp->get_color_model() != dest_cmodel)
469                 {
470                         delete temp;
471                         temp = 0;
472                 }
473                 
474                 if(!temp)
475                 {
476                         temp = new VFrame(0, frame->get_w(), frame->get_h(), dest_cmodel);
477                 }
478                 input_frame = temp;
480                 cmodel_transfer(input_frame->get_rows(), 
481                         frame->get_rows(),
482                         input_frame->get_y(),
483                         input_frame->get_u(),
484                         input_frame->get_v(),
485                         frame->get_y(),
486                         frame->get_u(),
487                         frame->get_v(),
488                         0, 
489                         0, 
490                         frame->get_w(), 
491                         frame->get_h(),
492                         0, 
493                         0, 
494                         frame->get_w(), 
495                         frame->get_h(),
496                         frame->get_color_model(), 
497                         input_frame->get_color_model(),
498                         0,
499                         frame->get_w(),
500                         frame->get_w());
501         }
502 //printf("FileTGA::write_tga 1\n");
504 // xorigin
505 // yorigin
506         header[8]  = header[9]  = 0;
507         header[10] = header[11] = 0;
509         header[12] = input_frame->get_w() % 256;
510         header[13] = input_frame->get_w() / 256;
512         header[14] = input_frame->get_h() % 256;
513         header[15] = input_frame->get_h() / 256;
514 //printf("FileTGA::write_tga 1\n");
515         
516         write_data(header, data, file_offset, sizeof(header));
517 //printf("FileTGA::write_tga 1\n");
519         unsigned char *output = new unsigned char[out_bpp * input_frame->get_w()];
520 //printf("FileTGA::write_tga 1\n");
521         for(int i = 0; i < input_frame->get_h(); i++)
522         {
523 //printf("FileTGA::write_tga 2\n");
524                 bgr2rgb(output, input_frame->get_rows()[i], input_frame->get_w(), out_bpp, (out_bpp == 4));
525 //printf("FileTGA::write_tga 3\n");
526                 
527                 if(rle)
528                 {
529 //printf("FileTGA::write_tga 4\n");
530                         rle_write(output, 
531                                 input_frame->get_w(), 
532                                 out_bpp,
533                                 data,
534                                 file_offset);
535 //printf("FileTGA::write_tga 5\n");
536                 }
537                 else
538                 {
539 //printf("FileTGA::write_tga 6\n");
540                         write_data(output, 
541                                 data, 
542                                 file_offset, 
543                                 input_frame->get_w() * out_bpp);
544 //printf("FileTGA::write_tga 7\n");
545                 }
546         }
547 //printf("FileTGA::write_tga 8\n");
548         delete [] output;
549 //printf("FileTGA::write_tga 9\n");
552 void FileTGA::write_data(unsigned char *buffer, 
553         VFrame *data, 
554         int64_t &file_offset,
555         int64_t len)
557 //printf("FileTGA::write_data 1 %d\n", len);
558         if(data->get_compressed_allocated() <= data->get_compressed_size() + len)
559         {
560                 data->allocate_compressed_data((data->get_compressed_size() + len) * 2);
561         }
562 //printf("FileTGA::write_data 1 %d\n", len);
564         bcopy(buffer, data->get_data() + file_offset, len);
565 //printf("FileTGA::write_data 1 %d\n", len);
566         file_offset += len;
567 //printf("FileTGA::write_data 1 %d\n", len);
568         data->set_compressed_size(file_offset);
569 //printf("FileTGA::write_data 2 %d\n", len);
572 void FileTGA::read_line(unsigned char *row,
573         unsigned char *data,
574         int64_t &file_offset,
575         int image_type,
576         int bpp,
577         int image_compression,
578         int bytes,
579         int width,
580         int fliphoriz,
581         int alphabits,
582         int data_size)
584         if(file_offset >= data_size) return;
585         if(image_compression == TGA_COMP_RLE)
586         {
587                 rle_read(row,
588                         data,
589                         file_offset,
590                         bytes,
591                         width);
592         }
593         else
594         {
595                 if(file_offset + bytes * width <= data_size)
596                         bcopy(data + file_offset, row, bytes * width);
597                 file_offset += bytes * width;
598         }
599         
600         if(fliphoriz)
601         {
602                 flip_line(row, bytes, width);
603         }
604         
605         if(image_type == TGA_TYPE_COLOR)
606         {
607                 if(bpp == 16)
608                 {
609                         upsample(row, row, width, bytes);
610                 }
611                 else
612                 {
613                         bgr2rgb(row, row, width, bytes, alphabits);
614                 }
615         }
616         else
617         {
618                 ;
619         }
622 void FileTGA::flip_line(unsigned char *row, int bytes, int width)
624         unsigned char temp;
625         unsigned char *alt;
626         int x, s;
628         alt = row + (bytes * (width - 1));
630         for (x = 0; x * 2 <= width; x++)
631     {
632         for(s = 0; s < bytes; ++s)
633                 {
634                         temp = row[s];
635                         row[s] = alt[s];
636                         alt[s] = temp;
637                 }
639         row += bytes;
640         alt -= bytes;
641     }
644 void FileTGA::rle_read(unsigned char *row,
645         unsigned char *data,
646         int64_t &file_offset,
647         int bytes,
648         int width)
650         int repeat = 0;
651         int direct = 0;
652         unsigned char sample[4];
653         int head;
655         for(int x = 0; x < width; x++)
656         {
657                 if(repeat == 0 && direct == 0)
658                 {
659                         head = data[file_offset++];
660                         if(head == EOF)
661                         {
662                                 return;
663                         }
664                         else
665                         if(head >= 128)
666                         {
667                                 repeat = head - 127;
668                                 bcopy(data + file_offset, sample, bytes);
669                                 file_offset += bytes;
670                         }
671                         else
672                         {
673                                 direct = head + 1;
674                         }
675                 }
676                 
677                 if(repeat > 0)
678                 {
679                         for(int k = 0; k < bytes; k++)
680                         {
681                                 row[k] = sample[k];
682                         }
683                         
684                         repeat--;
685                 }
686                 else
687                 {
688                         bcopy(data + file_offset, row, bytes);
689                         file_offset += bytes;
690                         
691                         direct--;
692                 }
693                 
694                 row += bytes;
695         }
698 void FileTGA::rle_write(unsigned char *buffer, 
699         int width, 
700         int bytes, 
701         VFrame *frame, 
702         int64_t &file_offset)
704         int repeat = 0;
705         int direct = 0;
706         unsigned char *from = buffer;
707         unsigned char output;
708         int x;
709         
710         for(x = 1; x < width; ++x)
711         {
712 /* next pixel is different */
713                 if(memcmp(buffer, buffer + bytes, bytes))
714                 {
715                         if(repeat)
716                         {
717                                 output = 128 + repeat;
718                                 write_data(&output, frame, file_offset, 1);
719                                 write_data(from, frame, file_offset, bytes);
720                                 from = buffer + bytes;
721                                 repeat = 0;
722                                 direct = 0;
723                         }
724                         else
725                         {
726                                 direct++;
727                         }
728                 }
729                 else
730 /* next pixel is the same */
731                 {
732                         if(direct)
733                         {
734                                 output = direct - 1;
735                                 write_data(&output, frame, file_offset, 1);
736                                 write_data(from, frame, file_offset, bytes * direct);
737                                 from = buffer;
738                                 direct = 0;
739                                 repeat = 1;
740                         }
741                         else
742                         {
743                                 repeat++;
744                         }
745                 }
746                 
747                 if(repeat == 128)
748                 {
749                         output = 255;
750                         write_data(&output, frame, file_offset, 1);
751                         write_data(from, frame, file_offset, bytes);
752                         from = buffer + bytes;
753                         direct = 0;
754                         repeat = 0;
755                 }
756                 else
757                 if(direct == 128)
758                 {
759                         output = 127;
760                         write_data(&output, frame, file_offset, 1);
761                         write_data(from, frame, file_offset, direct * bytes);
762                         from = buffer + bytes;
763                         direct = 0;
764                         repeat = 0;
765                 }
766                 
767                 buffer += bytes;
768         }
769         
770         if(repeat > 0)
771         {
772                 output = 128 + repeat;
773                 write_data(&output, frame, file_offset, 1);
774                 write_data(from, frame, file_offset, bytes);
775         }
776         else
777         {
778                 output = direct;
779                 write_data(&output, frame, file_offset, 1);
780                 write_data(from, frame, file_offset, bytes * (direct + 1));
781         }
785 void FileTGA::bgr2rgb(unsigned char *dest,
786          unsigned char *src,
787          int width,
788          int bytes,
789          int alpha)
791         int x;
792         unsigned char r, g, b;
794         if(alpha)
795     {
796         for(x = 0; x < width; x++)
797                 {
798                         r = src[2];
799                         g = src[1];
800                         b = src[0];
801                         *(dest++) = r;
802                         *(dest++) = g;
803                         *(dest++) = b;
804                         *(dest++) = src[3];
806                         src += bytes;
807                 }
808     }
809         else
810     {
811         for(x = 0; x < width; x++)
812                 {
813                         r = src[2];
814                         g = src[1];
815                         b = src[0];
816                         *(dest++) = r;
817                         *(dest++) = g;
818                         *(dest++) = b;
820                         src += bytes;
821                 }
822     }
825 void FileTGA::upsample(unsigned char *dest,
826           unsigned char *src,
827           int width,
828           int bytes)
830         int x;
832         dest += (width - 1) * 3;
833         src += (width - 1) * bytes;
834         for(x = width - 1; x >= 0; x--)
835     {
836         dest[0] =  ((src[1] << 1) & 0xf8);
837         dest[0] += (dest[0] >> 5);
839         dest[1] =  ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6);
840         dest[1] += (dest[1] >> 5);
842         dest[2] =  ((src[0] << 3) & 0xf8);
843         dest[2] += (dest[2] >> 5);
845         dest -= 3;
846         src -= bytes;
847     }
858 TGAUnit::TGAUnit(FileTGA *file, FrameWriter *writer)
859  : FrameWriterUnit(writer)
861         temp = 0;
862         this->file = file;
865 TGAUnit::~TGAUnit()
867         if(temp) delete temp;
882 TGAConfigVideo::TGAConfigVideo(BC_WindowBase *gui, Asset *asset)
883  : BC_Window(PROGRAM_NAME ": Video Compression",
884         gui->get_abs_cursor_x(1),
885         gui->get_abs_cursor_y(1),
886         400,
887         100)
889         this->gui = gui;
890         this->asset = asset;
892         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGB_RLE)));
893         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGBA_RLE)));
894         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGB)));
895         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGBA)));
898 TGAConfigVideo::~TGAConfigVideo()
900         compression_items.remove_all_objects();
903 int TGAConfigVideo::create_objects()
905         int x = 10, y = 10;
907         add_subwindow(new BC_Title(x, y, _("Compression:")));
908         TGACompression *textbox = new TGACompression(this, 
909                 x + 110, 
910                 y, 
911                 asset, 
912                 &compression_items);
913         textbox->create_objects();
914         add_subwindow(new BC_OKButton(this));
915         return 0;
918 int TGAConfigVideo::close_event()
920         set_done(0);
921         return 1;
925 TGACompression::TGACompression(TGAConfigVideo *gui,
926         int x, 
927         int y, 
928         Asset *asset, 
929         ArrayList<BC_ListBoxItem*> *compression_items)
930  : BC_PopupTextBox(gui,
931         compression_items,
932         FileTGA::compression_to_str(gui->asset->vcodec),
933         x, 
934         y, 
935         200,
936         200)
938         this->asset = asset;
940 int TGACompression::handle_event()
942         strcpy(asset->vcodec, FileTGA::str_to_compression(get_text()));
943         return 1;