Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / filetga.C
blob18d35bfc87d4433675b40def9ba7e57c03fb8ad9
1 #include "asset.h"
2 #include "bcsignals.h"
3 #include "bcwidgetgrid.h"
4 #include "edit.h"
5 #include "filetga.h"
6 #include "language.h"
7 #include "mwindow.inc"
8 #include "vframe.h"
9 #include "mainerror.h"
11 #include <string.h>
12 #include <unistd.h>
14 /* Known image types. */
15 #define TGA_TYPE_MAPPED      1
16 #define TGA_TYPE_COLOR       2
17 #define TGA_TYPE_GRAY        3
19 /* Only known compression is RLE */
20 #define TGA_COMP_NONE        0 
21 #define TGA_COMP_RLE         1 
24 FileTGA::FileTGA(Asset_GC asset, File *file)
25  : FileList(asset, file, "TGALIST", ".tga", FILE_TGA, FILE_TGA_LIST)
27         temp = 0;
30 FileTGA::~FileTGA()
32         if(temp) delete temp;
35 int FileTGA::check_sig(Asset_GC asset)
39 // Test file extension
40         int result = 0;
41         char *ext = strrchr(asset->path, '.');
43         if(ext)
44         {
46                 if(!strncasecmp(ext, ".tga", 4)) result = 1;
48         }
52 // Test for list
53         if(!result)
54         {
55                 FILE *stream;
56                 if(!(stream = fopen(asset->path, "rb")))
57                 {
58 // file not found
59                         result = 0;
60                 }
61                 else
62                 {
63                         char test[16];
64                         fread(test, 16, 1, stream);
65                         fclose(stream);
66                         if(test[0] == 'T' && test[1] == 'G' && test[2] == 'A' && 
67                                 test[3] == 'L' && test[4] == 'I' && test[5] == 'S' && 
68                                 test[6] == 'T')
69                         {
70                                 result = 1;
71                         }
72                         
73                 }
74         }
77         return result;
80 void FileTGA::get_parameters(BC_WindowBase *parent_window, 
81                 Asset_GC asset, 
82                 BC_WindowBase* &format_window,
83                 int audio_options,
84                 int video_options)
86         if(video_options)
87         {
88                 TGAConfigVideo *window = new TGAConfigVideo(parent_window, asset);
89                 format_window = window;
90                 window->create_objects();
91                 window->run_window();
92                 delete window;
93         }
96 #if 0
97 N_("RGB compressed")
98 N_("RGBA compressed")
99 N_("RGB uncompressed")
100 N_("RGBA uncompressed")
101 #endif
103 #define TGA_RGB_RLE "rle "
104 #define TGA_RGBA_RLE "rlea"
105 #define TGA_RGB "raw "
106 #define TGA_RGBA "rawa"
108 #define TGA_RGB_RLE_NAME "RGB compressed"
109 #define TGA_RGBA_RLE_NAME "RGBA compressed"
110 #define TGA_RGB_NAME "RGB uncompressed"
111 #define TGA_RGBA_NAME "RGBA uncompressed"
113 char* FileTGA::compression_to_str(char *compression)
115         if(!strcasecmp(compression, TGA_RGB_RLE)) return _(TGA_RGB_RLE_NAME);
116         if(!strcasecmp(compression, TGA_RGBA_RLE)) return _(TGA_RGBA_RLE_NAME);
117         if(!strcasecmp(compression, TGA_RGB)) return _(TGA_RGB_NAME);
118         if(!strcasecmp(compression, TGA_RGBA)) return _(TGA_RGBA_NAME);
119         return TGA_RGB_NAME;
122 char* FileTGA::str_to_compression(char *string)
124         if(!strcasecmp(compression_to_str(TGA_RGB_RLE), string)) return TGA_RGB_RLE;
125         if(!strcasecmp(compression_to_str(TGA_RGBA_RLE), string)) return TGA_RGBA_RLE;
126         if(!strcasecmp(compression_to_str(TGA_RGB), string)) return TGA_RGB;
127         if(!strcasecmp(compression_to_str(TGA_RGBA), string)) return TGA_RGBA;
128         return TGA_RGB;
131 int FileTGA::can_copy_from(Edit *edit, int64_t position)
133         if(edit->asset->format == FILE_TGA_LIST ||
134                 edit->asset->format == FILE_TGA)
135                 return 1;
136         
137         return 0;
141 int  FileTGA::colormodel_supported(int colormodel)
143         return colormodel;
146 int FileTGA::get_best_colormodel(Asset_GC asset, int driver)
148         if(!strcasecmp(asset->vcodec, TGA_RGB_RLE) || 
149                 !strcasecmp(asset->vcodec, TGA_RGB)) return BC_RGB888;
150         if(!strcasecmp(asset->vcodec, TGA_RGBA_RLE) ||
151                 !strcasecmp(asset->vcodec, TGA_RGBA)) return BC_RGBA8888;
152         return BC_RGB888;
155 int FileTGA::read_frame(VFrame *frame, VFrame *data)
157         read_tga(asset, frame, data, temp);
158         return 0;
161 int FileTGA::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
163         TGAUnit *tga_unit = (TGAUnit*)unit;
165         write_tga(asset, frame, data, tga_unit->temp);
166         return 0;
169 FrameWriterUnit* FileTGA::new_writer_unit(FrameWriter *writer)
171         return new TGAUnit(this, writer);
174 int64_t FileTGA::get_memory_usage()
176         int64_t result = FileList::get_memory_usage();
177         if(temp) result += temp->get_data_size();
178         return result;
188 #define FOOTERSIZE 26
189 #define HEADERSIZE 18
190 int FileTGA::read_frame_header(char *path)
192         int result = 0;
194 //printf("FileTGA::read_frame_header 1\n");
195         FILE *stream;
197         if(!(stream = fopen(path, "rb")))
198         {
199                 eprintf("Error while opening \"%s\" for reading. \n%m\n", asset->path);
200                 return 1;
201         }
203         unsigned char header[HEADERSIZE];
204         fread(header, HEADERSIZE, 1, stream);
205         fclose(stream);
207         asset->width = header[12] | (header[13] << 8);
208         asset->height = header[14] | (header[15] << 8);
209         int bpp = header[16];
210         int rle = header[2] & 0x8;
211         switch(bpp)
212         {
213                 case 32:
214                         if(rle) 
215                                 strcpy(asset->vcodec, TGA_RGBA_RLE);
216                         else
217                                 strcpy(asset->vcodec, TGA_RGBA);
218                         break;
219                 case 24:
220                         if(rle) 
221                                 strcpy(asset->vcodec, TGA_RGB_RLE);
222                         else
223                                 strcpy(asset->vcodec, TGA_RGB);
224                         break;
225         }
226 //printf("FileTGA::read_frame_header 2 %d %d\n", asset->width, asset->height);
228         return result;
231 void FileTGA::read_tga(Asset_GC asset, VFrame *frame, VFrame *data, VFrame* &temp)
233 // Read header
234         unsigned char *footer, *header;
235         int input_cmodel;
236         int64_t file_offset = 0;
238         footer = data->get_data() + 
239                 data->get_compressed_size() - 
240                 FOOTERSIZE;
241         header = data->get_data();
242         file_offset += HEADERSIZE;
244         int image_type;
245         int image_compression;
246         switch(header[2])
247         {
248                 case 1:
249                         image_type = TGA_TYPE_MAPPED;
250                         image_compression = TGA_COMP_NONE;
251                         break;
252                 case 2:
253                         image_type = TGA_TYPE_COLOR;
254                         image_compression = TGA_COMP_NONE;
255                         break;
256                 case 3:
257                         image_type = TGA_TYPE_GRAY;
258                         image_compression = TGA_COMP_NONE;
259                         break;
260                 case 9:
261                         image_type = TGA_TYPE_MAPPED;
262                         image_compression = TGA_COMP_RLE;
263                         break;
264                 case 10:
265                         image_type = TGA_TYPE_COLOR;
266                         image_compression = TGA_COMP_RLE;
267                         break;
268                 case 11:
269                         image_type = TGA_TYPE_GRAY;
270                         image_compression = TGA_COMP_RLE;
271                         break;
272                 default:
273                         image_type = 0;
274         }
275         
276         int idlength = header[0];
277         int colormaptype = header[1];
278         int colormapindex = header[3] + header[4] * 256;
279         int colormaplength = header[5] + header[6] * 256;
280         int colormapsize = header[7];
281         int xorigin = header[8] + header[9] * 256;
282         int yorigin = header[10] + header[11] * 256;
283         int width = header[12] + header[13] * 256;
284         int height = header[14] + header[15] * 256;
285         int bpp = header[16];
286         int bytes = (bpp + 7) / 8;
287         int alphabits = header[17] & 0x0f;
288         int fliphoriz = (header[17] & 0x10) ? 1 : 0;
289         int flipvert = (header[17] & 0x20) ? 0 : 1;
290         int data_size = data->get_compressed_size();
292         if(idlength) file_offset += idlength;
294 // Get colormap
295         unsigned char *tga_cmap;
296         unsigned char colormap[4 * 256];
298         if(colormaptype == 1)
299         {
300                 int cmap_bytes = (colormapsize + 7) / 8;
301                 tga_cmap = data->get_data() + file_offset;
302                 file_offset += colormaplength * cmap_bytes;
303                 
304                 switch(colormapsize)
305                 {
306                         case 32:
307                                 bgr2rgb(colormap, tga_cmap, colormaplength, cmap_bytes, 1);
308                                 break;
309                         case 24:
310                                 bgr2rgb(colormap, tga_cmap, colormaplength, cmap_bytes, 0);
311                                 break;
312                         case 16:
313                                 upsample(colormap, tga_cmap, colormaplength, cmap_bytes);
314                                 break;
315                 }
316         }
318         int source_cmodel = BC_RGB888;
319         switch(bpp)
320         {
321                 case 32:
322                         source_cmodel = BC_RGBA8888;
323                         break;
324                 case 24:
325                         source_cmodel = BC_RGB888;
326                         break;
327         }
329 // Read image
330         VFrame *output_frame;
331         if(frame->get_color_model() == source_cmodel)
332         {
333                 output_frame = frame;
334         }
335         else
336         {
337                 if(temp && temp->get_color_model() != source_cmodel)
338                 {
339                         delete temp;
340                         temp = 0;
341                 }
342                 
343                 if(!temp)
344                 {
345                         temp = new VFrame(0, width, height, source_cmodel);
346                 }
347                 output_frame = temp;
348         }
350         if(flipvert)
351         {
352                 for(int i = height - 1; i >= 0; i--)
353                 {
354                         read_line(output_frame->get_rows()[i], 
355                                 data->get_data(), 
356                                 file_offset,
357                                 image_type,
358                                 bpp,
359                                 image_compression,
360                                 bytes,
361                                 width,
362                                 fliphoriz,
363                                 alphabits,
364                                 data_size);
365                 }
366         }
367         else
368         {
369                 for(int i = 0; i < height; i++)
370                 {
371                         read_line(output_frame->get_rows()[i], 
372                                 data->get_data(), 
373                                 file_offset,
374                                 image_type,
375                                 bpp,
376                                 image_compression,
377                                 bytes,
378                                 width,
379                                 fliphoriz,
380                                 alphabits,
381                                 data_size);
382                 }
383         }
385         if(output_frame != frame)
386         {
387                 cmodel_transfer(frame->get_rows(), 
388                         output_frame->get_rows(),
389                         frame->get_y(),
390                         frame->get_u(),
391                         frame->get_v(),
392                         output_frame->get_y(),
393                         output_frame->get_u(),
394                         output_frame->get_v(),
395                         0, 
396                         0, 
397                         width, 
398                         height,
399                         0, 
400                         0, 
401                         frame->get_w(), 
402                         frame->get_h(),
403                         output_frame->get_color_model(), 
404                         frame->get_color_model(),
405                         0,
406                         width,
407                         frame->get_w());
408         }
411 void FileTGA::write_tga(Asset_GC asset, VFrame *frame, VFrame *data, VFrame* &temp)
413         unsigned char header[18];
414         unsigned char footer[26];
415         int64_t file_offset = 0;
416         int out_bpp = 0;
417         int rle = 0;
418         int dest_cmodel = BC_RGB888;
420 //printf("FileTGA::write_tga 1\n");
422         header[0] = 0;
423         header[1] = 0;
424         if(!strcasecmp(asset->vcodec, TGA_RGBA_RLE))
425         {
426                 header[2] = 10;
427         out_bpp = 4;
428                 rle = 1;
429         header[16] = 32; /* bpp */
430         header[17] = 0x28; /* alpha + orientation */
431                 dest_cmodel = BC_RGBA8888;
432         }
433         else
434         if(!strcasecmp(asset->vcodec, TGA_RGBA))
435         {
436                 header[2] = 2;
437         out_bpp = 4;
438                 rle = 0;
439         header[16] = 32; /* bpp */
440         header[17] = 0x28; /* alpha + orientation */
441                 dest_cmodel = BC_RGBA8888;
442         }
443         else
444         if(!strcasecmp(asset->vcodec, TGA_RGB_RLE))
445         {
446                 header[2] = 10;
447         out_bpp = 3;
448                 rle = 1;
449         header[16] = 24; /* bpp */
450         header[17] = 0x20; /* alpha + orientation */
451                 dest_cmodel = BC_RGB888;
452         }
453         else
454         {
455                 header[2] = 2;
456         out_bpp = 3;
457                 rle = 0;
458         header[16] = 24; /* bpp */
459         header[17] = 0x20; /* alpha + orientation */
460                 dest_cmodel = BC_RGB888;
461         }
462     header[3] = header[4] = header[5] = header[6] = header[7] = 0;
463 //printf("FileTGA::write_tga 1\n");
465         VFrame *input_frame;
466         if(frame->get_color_model() == dest_cmodel)
467         {
468                 input_frame = frame;
469         }
470         else
471         {
472                 if(temp && temp->get_color_model() != dest_cmodel)
473                 {
474                         delete temp;
475                         temp = 0;
476                 }
477                 
478                 if(!temp)
479                 {
480                         temp = new VFrame(0, frame->get_w(), frame->get_h(), dest_cmodel);
481                 }
482                 input_frame = temp;
484                 cmodel_transfer(input_frame->get_rows(), 
485                         frame->get_rows(),
486                         input_frame->get_y(),
487                         input_frame->get_u(),
488                         input_frame->get_v(),
489                         frame->get_y(),
490                         frame->get_u(),
491                         frame->get_v(),
492                         0, 
493                         0, 
494                         frame->get_w(), 
495                         frame->get_h(),
496                         0, 
497                         0, 
498                         frame->get_w(), 
499                         frame->get_h(),
500                         frame->get_color_model(), 
501                         input_frame->get_color_model(),
502                         0,
503                         frame->get_w(),
504                         frame->get_w());
505         }
506 //printf("FileTGA::write_tga 1\n");
508 // xorigin
509 // yorigin
510         header[8]  = header[9]  = 0;
511         header[10] = header[11] = 0;
513         header[12] = input_frame->get_w() % 256;
514         header[13] = input_frame->get_w() / 256;
516         header[14] = input_frame->get_h() % 256;
517         header[15] = input_frame->get_h() / 256;
518 //printf("FileTGA::write_tga 1\n");
519         
520         write_data(header, data, file_offset, sizeof(header));
521 //printf("FileTGA::write_tga 1\n");
523         unsigned char *output = new unsigned char[out_bpp * input_frame->get_w()];
524 //printf("FileTGA::write_tga 1\n");
525         for(int i = 0; i < input_frame->get_h(); i++)
526         {
527 //printf("FileTGA::write_tga 2\n");
528                 bgr2rgb(output, input_frame->get_rows()[i], input_frame->get_w(), out_bpp, (out_bpp == 4));
529 //printf("FileTGA::write_tga 3\n");
530                 
531                 if(rle)
532                 {
533 //printf("FileTGA::write_tga 4\n");
534                         rle_write(output, 
535                                 input_frame->get_w(), 
536                                 out_bpp,
537                                 data,
538                                 file_offset);
539 //printf("FileTGA::write_tga 5\n");
540                 }
541                 else
542                 {
543 //printf("FileTGA::write_tga 6\n");
544                         write_data(output, 
545                                 data, 
546                                 file_offset, 
547                                 input_frame->get_w() * out_bpp);
548 //printf("FileTGA::write_tga 7\n");
549                 }
550         }
551 //printf("FileTGA::write_tga 8\n");
552         delete [] output;
553 //printf("FileTGA::write_tga 9\n");
556 void FileTGA::write_data(unsigned char *buffer, 
557         VFrame *data, 
558         int64_t &file_offset,
559         int64_t len)
561 //printf("FileTGA::write_data 1 %d\n", len);
562         if(data->get_compressed_allocated() <= data->get_compressed_size() + len)
563         {
564                 data->allocate_compressed_data((data->get_compressed_size() + len) * 2);
565         }
566 //printf("FileTGA::write_data 1 %d\n", len);
568         bcopy(buffer, data->get_data() + file_offset, len);
569 //printf("FileTGA::write_data 1 %d\n", len);
570         file_offset += len;
571 //printf("FileTGA::write_data 1 %d\n", len);
572         data->set_compressed_size(file_offset);
573 //printf("FileTGA::write_data 2 %d\n", len);
576 void FileTGA::read_line(unsigned char *row,
577         unsigned char *data,
578         int64_t &file_offset,
579         int image_type,
580         int bpp,
581         int image_compression,
582         int bytes,
583         int width,
584         int fliphoriz,
585         int alphabits,
586         int data_size)
588         if(file_offset >= data_size) return;
589         if(image_compression == TGA_COMP_RLE)
590         {
591                 rle_read(row,
592                         data,
593                         file_offset,
594                         bytes,
595                         width);
596         }
597         else
598         {
599                 if(file_offset + bytes * width <= data_size)
600                         bcopy(data + file_offset, row, bytes * width);
601                 file_offset += bytes * width;
602         }
603         
604         if(fliphoriz)
605         {
606                 flip_line(row, bytes, width);
607         }
608         
609         if(image_type == TGA_TYPE_COLOR)
610         {
611                 if(bpp == 16)
612                 {
613                         upsample(row, row, width, bytes);
614                 }
615                 else
616                 {
617                         bgr2rgb(row, row, width, bytes, alphabits);
618                 }
619         }
620         else
621         {
622                 ;
623         }
626 void FileTGA::flip_line(unsigned char *row, int bytes, int width)
628         unsigned char temp;
629         unsigned char *alt;
630         int x, s;
632         alt = row + (bytes * (width - 1));
634         for (x = 0; x * 2 <= width; x++)
635     {
636         for(s = 0; s < bytes; ++s)
637                 {
638                         temp = row[s];
639                         row[s] = alt[s];
640                         alt[s] = temp;
641                 }
643         row += bytes;
644         alt -= bytes;
645     }
648 void FileTGA::rle_read(unsigned char *row,
649         unsigned char *data,
650         int64_t &file_offset,
651         int bytes,
652         int width)
654         int repeat = 0;
655         int direct = 0;
656         unsigned char sample[4];
657         int head;
659         for(int x = 0; x < width; x++)
660         {
661                 if(repeat == 0 && direct == 0)
662                 {
663                         head = data[file_offset++];
664                         if(head == EOF)
665                         {
666                                 return;
667                         }
668                         else
669                         if(head >= 128)
670                         {
671                                 repeat = head - 127;
672                                 bcopy(data + file_offset, sample, bytes);
673                                 file_offset += bytes;
674                         }
675                         else
676                         {
677                                 direct = head + 1;
678                         }
679                 }
680                 
681                 if(repeat > 0)
682                 {
683                         for(int k = 0; k < bytes; k++)
684                         {
685                                 row[k] = sample[k];
686                         }
687                         
688                         repeat--;
689                 }
690                 else
691                 {
692                         bcopy(data + file_offset, row, bytes);
693                         file_offset += bytes;
694                         
695                         direct--;
696                 }
697                 
698                 row += bytes;
699         }
702 void FileTGA::rle_write(unsigned char *buffer, 
703         int width, 
704         int bytes, 
705         VFrame *frame, 
706         int64_t &file_offset)
708         int repeat = 0;
709         int direct = 0;
710         unsigned char *from = buffer;
711         unsigned char output;
712         int x;
713         
714         for(x = 1; x < width; ++x)
715         {
716 /* next pixel is different */
717                 if(memcmp(buffer, buffer + bytes, bytes))
718                 {
719                         if(repeat)
720                         {
721                                 output = 128 + repeat;
722                                 write_data(&output, frame, file_offset, 1);
723                                 write_data(from, frame, file_offset, bytes);
724                                 from = buffer + bytes;
725                                 repeat = 0;
726                                 direct = 0;
727                         }
728                         else
729                         {
730                                 direct++;
731                         }
732                 }
733                 else
734 /* next pixel is the same */
735                 {
736                         if(direct)
737                         {
738                                 output = direct - 1;
739                                 write_data(&output, frame, file_offset, 1);
740                                 write_data(from, frame, file_offset, bytes * direct);
741                                 from = buffer;
742                                 direct = 0;
743                                 repeat = 1;
744                         }
745                         else
746                         {
747                                 repeat++;
748                         }
749                 }
750                 
751                 if(repeat == 128)
752                 {
753                         output = 255;
754                         write_data(&output, frame, file_offset, 1);
755                         write_data(from, frame, file_offset, bytes);
756                         from = buffer + bytes;
757                         direct = 0;
758                         repeat = 0;
759                 }
760                 else
761                 if(direct == 128)
762                 {
763                         output = 127;
764                         write_data(&output, frame, file_offset, 1);
765                         write_data(from, frame, file_offset, direct * bytes);
766                         from = buffer + bytes;
767                         direct = 0;
768                         repeat = 0;
769                 }
770                 
771                 buffer += bytes;
772         }
773         
774         if(repeat > 0)
775         {
776                 output = 128 + repeat;
777                 write_data(&output, frame, file_offset, 1);
778                 write_data(from, frame, file_offset, bytes);
779         }
780         else
781         {
782                 output = direct;
783                 write_data(&output, frame, file_offset, 1);
784                 write_data(from, frame, file_offset, bytes * (direct + 1));
785         }
789 void FileTGA::bgr2rgb(unsigned char *dest,
790          unsigned char *src,
791          int width,
792          int bytes,
793          int alpha)
795         int x;
796         unsigned char r, g, b;
798         if(alpha)
799     {
800         for(x = 0; x < width; x++)
801                 {
802                         r = src[2];
803                         g = src[1];
804                         b = src[0];
805                         *(dest++) = r;
806                         *(dest++) = g;
807                         *(dest++) = b;
808                         *(dest++) = src[3];
810                         src += bytes;
811                 }
812     }
813         else
814     {
815         for(x = 0; x < width; x++)
816                 {
817                         r = src[2];
818                         g = src[1];
819                         b = src[0];
820                         *(dest++) = r;
821                         *(dest++) = g;
822                         *(dest++) = b;
824                         src += bytes;
825                 }
826     }
829 void FileTGA::upsample(unsigned char *dest,
830           unsigned char *src,
831           int width,
832           int bytes)
834         int x;
836         dest += (width - 1) * 3;
837         src += (width - 1) * bytes;
838         for(x = width - 1; x >= 0; x--)
839     {
840         dest[0] =  ((src[1] << 1) & 0xf8);
841         dest[0] += (dest[0] >> 5);
843         dest[1] =  ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6);
844         dest[1] += (dest[1] >> 5);
846         dest[2] =  ((src[0] << 3) & 0xf8);
847         dest[2] += (dest[2] >> 5);
849         dest -= 3;
850         src -= bytes;
851     }
862 TGAUnit::TGAUnit(FileTGA *file, FrameWriter *writer)
863  : FrameWriterUnit(writer)
865         temp = 0;
866         this->file = file;
869 TGAUnit::~TGAUnit()
871         if(temp) delete temp;
886 TGAConfigVideo::TGAConfigVideo(BC_WindowBase *gui, Asset_GC asset)
887  : BC_Window(PROGRAM_NAME ": Video Compression",
888         gui->get_abs_cursor_x(1),
889         gui->get_abs_cursor_y(1),
890         400,
891         100,
892         400,
893         100,
894         0,
895         1)
897         this->gui = gui;
898         this->asset = asset;
900         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGB_RLE)));
901         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGBA_RLE)));
902         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGB)));
903         compression_items.append(new BC_ListBoxItem(FileTGA::compression_to_str(TGA_RGBA)));
906 TGAConfigVideo::~TGAConfigVideo()
908         compression_items.remove_all_objects();
911 int TGAConfigVideo::create_objects()
913         int x = 10, y = 10;
915         BC_WidgetGrid *wg;
916         BC_RelocatableWidget *rw;
918         wg = add_widgetgrid(new BC_WidgetGrid(10, 10, 10, 10, 3, 3));
920         rw =
921         add_subwindow(new BC_Title(x, y, _("Compression:")));
922         TGACompression *textbox = new TGACompression(this, 
923                 x + 110, 
924                 y, 
925                 asset, 
926                 &compression_items);
927         textbox->create_objects();
929         wg->add(rw, 0, 0);
930         wg->add(textbox, 0, 1);
932         rw =
933         add_subwindow(new BC_OKButton(this));
935         wg->move_widgets();
936         resize_window(wg->get_w_wm(), wg->get_h_wm() + rw->get_h());
937         return 0;
940 int TGAConfigVideo::close_event()
942         set_done(0);
943         return 1;
947 TGACompression::TGACompression(TGAConfigVideo *gui,
948         int x, 
949         int y, 
950         Asset_GC asset, 
951         ArrayList<BC_ListBoxItem*> *compression_items)
952  : BC_PopupTextBox(gui,
953         compression_items,
954         FileTGA::compression_to_str(gui->asset->vcodec),
955         x, 
956         y, 
957         200,
958         200)
960         this->asset = asset;
962 int TGACompression::handle_event()
964         strcpy(asset->vcodec, FileTGA::str_to_compression(get_text()));
965         return 1;
968 //      Local Variables:
969 //      mode: C++
970 //      c-file-style: "linux"
971 //      End: