r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / filetga.C
blob34670ddf69b5f3998f1c097c6c7530824098164a
1 #include "assets.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);
179 #define FOOTERSIZE 26
180 #define HEADERSIZE 18
181 int FileTGA::read_frame_header(char *path)
183         int result = 0;
185 //printf("FileTGA::read_frame_header 1\n");
186         FILE *stream;
188         if(!(stream = fopen(path, "rb")))
189         {
190                 perror("FileTGA::read_frame_header");
191                 return 1;
192         }
194         unsigned char header[HEADERSIZE];
195         fread(header, HEADERSIZE, 1, stream);
196         fclose(stream);
198         asset->width = header[12] | (header[13] << 8);
199         asset->height = header[14] | (header[15] << 8);
200         int bpp = header[16];
201         int rle = header[2] & 0x8;
202         switch(bpp)
203         {
204                 case 32:
205                         if(rle) 
206                                 strcpy(asset->vcodec, TGA_RGBA_RLE);
207                         else
208                                 strcpy(asset->vcodec, TGA_RGBA);
209                         break;
210                 case 24:
211                         if(rle) 
212                                 strcpy(asset->vcodec, TGA_RGB_RLE);
213                         else
214                                 strcpy(asset->vcodec, TGA_RGB);
215                         break;
216         }
217 //printf("FileTGA::read_frame_header 2 %d %d\n", asset->width, asset->height);
219         return result;
222 void FileTGA::read_tga(Asset *asset, VFrame *frame, VFrame *data, VFrame* &temp)
224 //printf("FileTGA::read_tga 1\n");
225 // Read header
226         unsigned char *footer, *header;
227         int input_cmodel;
228         int64_t file_offset = 0;
230         footer = data->get_data() + 
231                 data->get_compressed_size() - 
232                 FOOTERSIZE;
233         header = data->get_data();
234         file_offset += HEADERSIZE;
236         int image_type;
237         int image_compression;
238         switch(header[2])
239         {
240                 case 1:
241                         image_type = TGA_TYPE_MAPPED;
242                         image_compression = TGA_COMP_NONE;
243                         break;
244                 case 2:
245                         image_type = TGA_TYPE_COLOR;
246                         image_compression = TGA_COMP_NONE;
247                         break;
248                 case 3:
249                         image_type = TGA_TYPE_GRAY;
250                         image_compression = TGA_COMP_NONE;
251                         break;
252                 case 9:
253                         image_type = TGA_TYPE_MAPPED;
254                         image_compression = TGA_COMP_RLE;
255                         break;
256                 case 10:
257                         image_type = TGA_TYPE_COLOR;
258                         image_compression = TGA_COMP_RLE;
259                         break;
260                 case 11:
261                         image_type = TGA_TYPE_GRAY;
262                         image_compression = TGA_COMP_RLE;
263                         break;
264                 default:
265                         image_type = 0;
266         }
267         
268         int idlength = header[0];
269         int colormaptype = header[1];
270         int colormapindex = header[3] + header[4] * 256;
271         int colormaplength = header[5] + header[6] * 256;
272         int colormapsize = header[7];
273         int xorigin = header[8] + header[9] * 256;
274         int yorigin = header[10] + header[11] * 256;
275         int width = header[12] + header[13] * 256;
276         int height = header[14] + header[15] * 256;
277         int bpp = header[16];
278         int bytes = (bpp + 7) / 8;
279         int alphabits = header[17] & 0x0f;
280         int fliphoriz = (header[17] & 0x10) ? 1 : 0;
281         int flipvert = (header[17] & 0x20) ? 0 : 1;
282         int data_size = data->get_compressed_size();
284         if(idlength) file_offset += idlength;
286 // Get colormap
287         unsigned char *tga_cmap;
288         unsigned char colormap[4 * 256];
290         if(colormaptype == 1)
291         {
292                 int cmap_bytes = (colormapsize + 7) / 8;
293                 tga_cmap = data->get_data() + file_offset;
294                 file_offset += colormaplength * cmap_bytes;
295                 
296                 switch(colormapsize)
297                 {
298                         case 32:
299                                 bgr2rgb(colormap, tga_cmap, colormaplength, cmap_bytes, 1);
300                                 break;
301                         case 24:
302                                 bgr2rgb(colormap, tga_cmap, colormaplength, cmap_bytes, 0);
303                                 break;
304                         case 16:
305                                 upsample(colormap, tga_cmap, colormaplength, cmap_bytes);
306                                 break;
307                 }
308         }
310         int source_cmodel = BC_RGB888;
311         switch(bpp)
312         {
313                 case 32:
314                         source_cmodel = BC_RGBA8888;
315                         break;
316                 case 24:
317                         source_cmodel = BC_RGB888;
318                         break;
319         }
321 // Read image
322         VFrame *output_frame;
323         if(frame->get_color_model() == source_cmodel)
324         {
325                 output_frame = frame;
326         }
327         else
328         {
329                 if(temp && temp->get_color_model() != source_cmodel)
330                 {
331                         delete temp;
332                         temp = 0;
333                 }
334                 
335                 if(!temp)
336                 {
337                         temp = new VFrame(0, width, height, source_cmodel);
338                 }
339                 output_frame = temp;
340         }
342         if(flipvert)
343         {
344                 for(int i = height - 1; i >= 0; i--)
345                 {
346                         read_line(output_frame->get_rows()[i], 
347                                 data->get_data(), 
348                                 file_offset,
349                                 image_type,
350                                 bpp,
351                                 image_compression,
352                                 bytes,
353                                 width,
354                                 fliphoriz,
355                                 alphabits,
356                                 data_size);
357                 }
358         }
359         else
360         {
361                 for(int i = 0; i < height; i++)
362                 {
363                         read_line(output_frame->get_rows()[i], 
364                                 data->get_data(), 
365                                 file_offset,
366                                 image_type,
367                                 bpp,
368                                 image_compression,
369                                 bytes,
370                                 width,
371                                 fliphoriz,
372                                 alphabits,
373                                 data_size);
374                 }
375         }
377         if(output_frame != frame)
378         {
379                 cmodel_transfer(frame->get_rows(), 
380                         output_frame->get_rows(),
381                         frame->get_y(),
382                         frame->get_u(),
383                         frame->get_v(),
384                         output_frame->get_y(),
385                         output_frame->get_u(),
386                         output_frame->get_v(),
387                         0, 
388                         0, 
389                         width, 
390                         height,
391                         0, 
392                         0, 
393                         frame->get_w(), 
394                         frame->get_h(),
395                         output_frame->get_color_model(), 
396                         frame->get_color_model(),
397                         0,
398                         width,
399                         frame->get_w());
400         }
401 //printf("FileTGA::read_tga 2 %d %d\n", frame->get_color_model(), output_frame->get_color_model());
404 void FileTGA::write_tga(Asset *asset, VFrame *frame, VFrame *data, VFrame* &temp)
406         unsigned char header[18];
407         unsigned char footer[26];
408         int64_t file_offset = 0;
409         int out_bpp = 0;
410         int rle = 0;
411         int dest_cmodel = BC_RGB888;
413 //printf("FileTGA::write_tga 1\n");
415         header[0] = 0;
416         header[1] = 0;
417         if(!strcasecmp(asset->vcodec, TGA_RGBA_RLE))
418         {
419                 header[2] = 10;
420         out_bpp = 4;
421                 rle = 1;
422         header[16] = 32; /* bpp */
423         header[17] = 0x28; /* alpha + orientation */
424                 dest_cmodel = BC_RGBA8888;
425         }
426         else
427         if(!strcasecmp(asset->vcodec, TGA_RGBA))
428         {
429                 header[2] = 2;
430         out_bpp = 4;
431                 rle = 0;
432         header[16] = 32; /* bpp */
433         header[17] = 0x28; /* alpha + orientation */
434                 dest_cmodel = BC_RGBA8888;
435         }
436         else
437         if(!strcasecmp(asset->vcodec, TGA_RGB_RLE))
438         {
439                 header[2] = 10;
440         out_bpp = 3;
441                 rle = 1;
442         header[16] = 24; /* bpp */
443         header[17] = 0x20; /* alpha + orientation */
444                 dest_cmodel = BC_RGB888;
445         }
446         else
447         {
448                 header[2] = 2;
449         out_bpp = 3;
450                 rle = 0;
451         header[16] = 24; /* bpp */
452         header[17] = 0x20; /* alpha + orientation */
453                 dest_cmodel = BC_RGB888;
454         }
455     header[3] = header[4] = header[5] = header[6] = header[7] = 0;
456 //printf("FileTGA::write_tga 1\n");
458         VFrame *input_frame;
459         if(frame->get_color_model() == dest_cmodel)
460         {
461                 input_frame = frame;
462         }
463         else
464         {
465                 if(temp && temp->get_color_model() != dest_cmodel)
466                 {
467                         delete temp;
468                         temp = 0;
469                 }
470                 
471                 if(!temp)
472                 {
473                         temp = new VFrame(0, frame->get_w(), frame->get_h(), dest_cmodel);
474                 }
475                 input_frame = temp;
477                 cmodel_transfer(input_frame->get_rows(), 
478                         frame->get_rows(),
479                         input_frame->get_y(),
480                         input_frame->get_u(),
481                         input_frame->get_v(),
482                         frame->get_y(),
483                         frame->get_u(),
484                         frame->get_v(),
485                         0, 
486                         0, 
487                         frame->get_w(), 
488                         frame->get_h(),
489                         0, 
490                         0, 
491                         frame->get_w(), 
492                         frame->get_h(),
493                         frame->get_color_model(), 
494                         input_frame->get_color_model(),
495                         0,
496                         frame->get_w(),
497                         frame->get_w());
498         }
499 //printf("FileTGA::write_tga 1\n");
501 // xorigin
502 // yorigin
503         header[8]  = header[9]  = 0;
504         header[10] = header[11] = 0;
506         header[12] = input_frame->get_w() % 256;
507         header[13] = input_frame->get_w() / 256;
509         header[14] = input_frame->get_h() % 256;
510         header[15] = input_frame->get_h() / 256;
511 //printf("FileTGA::write_tga 1\n");
512         
513         write_data(header, data, file_offset, sizeof(header));
514 //printf("FileTGA::write_tga 1\n");
516         unsigned char *output = new unsigned char[out_bpp * input_frame->get_w()];
517 //printf("FileTGA::write_tga 1\n");
518         for(int i = 0; i < input_frame->get_h(); i++)
519         {
520 //printf("FileTGA::write_tga 2\n");
521                 bgr2rgb(output, input_frame->get_rows()[i], input_frame->get_w(), out_bpp, (out_bpp == 4));
522 //printf("FileTGA::write_tga 3\n");
523                 
524                 if(rle)
525                 {
526 //printf("FileTGA::write_tga 4\n");
527                         rle_write(output, 
528                                 input_frame->get_w(), 
529                                 out_bpp,
530                                 data,
531                                 file_offset);
532 //printf("FileTGA::write_tga 5\n");
533                 }
534                 else
535                 {
536 //printf("FileTGA::write_tga 6\n");
537                         write_data(output, 
538                                 data, 
539                                 file_offset, 
540                                 input_frame->get_w() * out_bpp);
541 //printf("FileTGA::write_tga 7\n");
542                 }
543         }
544 //printf("FileTGA::write_tga 8\n");
545         delete [] output;
546 //printf("FileTGA::write_tga 9\n");
549 void FileTGA::write_data(unsigned char *buffer, 
550         VFrame *data, 
551         int64_t &file_offset,
552         int64_t len)
554 //printf("FileTGA::write_data 1 %d\n", len);
555         if(data->get_compressed_allocated() <= data->get_compressed_size() + len)
556         {
557                 data->allocate_compressed_data((data->get_compressed_size() + len) * 2);
558         }
559 //printf("FileTGA::write_data 1 %d\n", len);
561         bcopy(buffer, data->get_data() + file_offset, len);
562 //printf("FileTGA::write_data 1 %d\n", len);
563         file_offset += len;
564 //printf("FileTGA::write_data 1 %d\n", len);
565         data->set_compressed_size(file_offset);
566 //printf("FileTGA::write_data 2 %d\n", len);
569 void FileTGA::read_line(unsigned char *row,
570         unsigned char *data,
571         int64_t &file_offset,
572         int image_type,
573         int bpp,
574         int image_compression,
575         int bytes,
576         int width,
577         int fliphoriz,
578         int alphabits,
579         int data_size)
581         if(file_offset >= data_size) return;
582         if(image_compression == TGA_COMP_RLE)
583         {
584                 rle_read(row,
585                         data,
586                         file_offset,
587                         bytes,
588                         width);
589         }
590         else
591         {
592                 if(file_offset + bytes * width <= data_size)
593                         bcopy(data + file_offset, row, bytes * width);
594                 file_offset += bytes * width;
595         }
596         
597         if(fliphoriz)
598         {
599                 flip_line(row, bytes, width);
600         }
601         
602         if(image_type == TGA_TYPE_COLOR)
603         {
604                 if(bpp == 16)
605                 {
606                         upsample(row, row, width, bytes);
607                 }
608                 else
609                 {
610                         bgr2rgb(row, row, width, bytes, alphabits);
611                 }
612         }
613         else
614         {
615                 ;
616         }
619 void FileTGA::flip_line(unsigned char *row, int bytes, int width)
621         unsigned char temp;
622         unsigned char *alt;
623         int x, s;
625         alt = row + (bytes * (width - 1));
627         for (x = 0; x * 2 <= width; x++)
628     {
629         for(s = 0; s < bytes; ++s)
630                 {
631                         temp = row[s];
632                         row[s] = alt[s];
633                         alt[s] = temp;
634                 }
636         row += bytes;
637         alt -= bytes;
638     }
641 void FileTGA::rle_read(unsigned char *row,
642         unsigned char *data,
643         int64_t &file_offset,
644         int bytes,
645         int width)
647         int repeat = 0;
648         int direct = 0;
649         unsigned char sample[4];
650         int head;
652         for(int x = 0; x < width; x++)
653         {
654                 if(repeat == 0 && direct == 0)
655                 {
656                         head = data[file_offset++];
657                         if(head == EOF)
658                         {
659                                 return;
660                         }
661                         else
662                         if(head >= 128)
663                         {
664                                 repeat = head - 127;
665                                 bcopy(data + file_offset, sample, bytes);
666                                 file_offset += bytes;
667                         }
668                         else
669                         {
670                                 direct = head + 1;
671                         }
672                 }
673                 
674                 if(repeat > 0)
675                 {
676                         for(int k = 0; k < bytes; k++)
677                         {
678                                 row[k] = sample[k];
679                         }
680                         
681                         repeat--;
682                 }
683                 else
684                 {
685                         bcopy(data + file_offset, row, bytes);
686                         file_offset += bytes;
687                         
688                         direct--;
689                 }
690                 
691                 row += bytes;
692         }
695 void FileTGA::rle_write(unsigned char *buffer, 
696         int width, 
697         int bytes, 
698         VFrame *frame, 
699         int64_t &file_offset)
701         int repeat = 0;
702         int direct = 0;
703         unsigned char *from = buffer;
704         unsigned char output;
705         int x;
706         
707         for(x = 1; x < width; ++x)
708         {
709 /* next pixel is different */
710                 if(memcmp(buffer, buffer + bytes, bytes))
711                 {
712                         if(repeat)
713                         {
714                                 output = 128 + repeat;
715                                 write_data(&output, frame, file_offset, 1);
716                                 write_data(from, frame, file_offset, bytes);
717                                 from = buffer + bytes;
718                                 repeat = 0;
719                                 direct = 0;
720                         }
721                         else
722                         {
723                                 direct++;
724                         }
725                 }
726                 else
727 /* next pixel is the same */
728                 {
729                         if(direct)
730                         {
731                                 output = direct - 1;
732                                 write_data(&output, frame, file_offset, 1);
733                                 write_data(from, frame, file_offset, bytes * direct);
734                                 from = buffer;
735                                 direct = 0;
736                                 repeat = 1;
737                         }
738                         else
739                         {
740                                 repeat++;
741                         }
742                 }
743                 
744                 if(repeat == 128)
745                 {
746                         output = 255;
747                         write_data(&output, frame, file_offset, 1);
748                         write_data(from, frame, file_offset, bytes);
749                         from = buffer + bytes;
750                         direct = 0;
751                         repeat = 0;
752                 }
753                 else
754                 if(direct == 128)
755                 {
756                         output = 127;
757                         write_data(&output, frame, file_offset, 1);
758                         write_data(from, frame, file_offset, direct * bytes);
759                         from = buffer + bytes;
760                         direct = 0;
761                         repeat = 0;
762                 }
763                 
764                 buffer += bytes;
765         }
766         
767         if(repeat > 0)
768         {
769                 output = 128 + repeat;
770                 write_data(&output, frame, file_offset, 1);
771                 write_data(from, frame, file_offset, bytes);
772         }
773         else
774         {
775                 output = direct;
776                 write_data(&output, frame, file_offset, 1);
777                 write_data(from, frame, file_offset, bytes * (direct + 1));
778         }
782 void FileTGA::bgr2rgb(unsigned char *dest,
783          unsigned char *src,
784          int width,
785          int bytes,
786          int alpha)
788         int x;
789         unsigned char r, g, b;
791         if(alpha)
792     {
793         for(x = 0; x < width; x++)
794                 {
795                         r = src[2];
796                         g = src[1];
797                         b = src[0];
798                         *(dest++) = r;
799                         *(dest++) = g;
800                         *(dest++) = b;
801                         *(dest++) = src[3];
803                         src += bytes;
804                 }
805     }
806         else
807     {
808         for(x = 0; x < width; x++)
809                 {
810                         r = src[2];
811                         g = src[1];
812                         b = src[0];
813                         *(dest++) = r;
814                         *(dest++) = g;
815                         *(dest++) = b;
817                         src += bytes;
818                 }
819     }
822 void FileTGA::upsample(unsigned char *dest,
823           unsigned char *src,
824           int width,
825           int bytes)
827         int x;
829         dest += (width - 1) * 3;
830         src += (width - 1) * bytes;
831         for(x = width - 1; x >= 0; x--)
832     {
833         dest[0] =  ((src[1] << 1) & 0xf8);
834         dest[0] += (dest[0] >> 5);
836         dest[1] =  ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6);
837         dest[1] += (dest[1] >> 5);
839         dest[2] =  ((src[0] << 3) & 0xf8);
840         dest[2] += (dest[2] >> 5);
842         dest -= 3;
843         src -= bytes;
844     }
855 TGAUnit::TGAUnit(FileTGA *file, FrameWriter *writer)
856  : FrameWriterUnit(writer)
858         temp = 0;
859         this->file = file;
862 TGAUnit::~TGAUnit()
864         if(temp) delete temp;
879 TGAConfigVideo::TGAConfigVideo(BC_WindowBase *gui, Asset *asset)
880  : BC_Window(PROGRAM_NAME ": Video Compression",
881         gui->get_abs_cursor_x(),
882         gui->get_abs_cursor_y(),
883         400,
884         100)
886         this->gui = gui;
887         this->asset = asset;
889         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGB_RLE)));
890         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGBA_RLE)));
891         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGB)));
892         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGBA)));
895 TGAConfigVideo::~TGAConfigVideo()
897         compression_items.remove_all_objects();
900 int TGAConfigVideo::create_objects()
902         int x = 10, y = 10;
904         add_subwindow(new BC_Title(x, y, _("Compression:")));
905         TGACompression *textbox = new TGACompression(this, 
906                 x + 110, 
907                 y, 
908                 asset, 
909                 &compression_items);
910         textbox->create_objects();
911         add_subwindow(new BC_OKButton(this));
912         return 0;
915 int TGAConfigVideo::close_event()
917         set_done(0);
918         return 1;
922 TGACompression::TGACompression(TGAConfigVideo *gui,
923         int x, 
924         int y, 
925         Asset *asset, 
926         ArrayList<BC_ListBoxItem*> *compression_items)
927  : BC_PopupTextBox(gui,
928         compression_items,
929         FileTGA::compression_to_str(gui->asset->vcodec),
930         x, 
931         y, 
932         200,
933         200)
935         this->asset = asset;
937 int TGACompression::handle_event()
939         strcpy(asset->vcodec, FileTGA::str_to_compression(get_text()));
940         return 1;