home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Library / BCBViewer / PngConfig.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-17  |  2.6 KB  |  84 lines

  1. //
  2. // Copyright (c) 1998 Colosseum Builders, Inc.
  3. // All rights reserved.
  4. //
  5. // Colosseum Builders, Inc. makes no warranty, expressed or implied
  6. // with regards to this software. It is provided as is.
  7. //
  8. // Permission to use, redistribute, and copy this file is granted
  9. // without a fee so long as as the following conditions are adhered to:
  10. //
  11. // o The user assumes all risk for using this software. The authors of this
  12. //   software shall be liable for no damages of any kind.
  13. //
  14. // o If the source code is distributed then this copyright notice must
  15. //   remain unaltered and any modification must be noted.
  16. //
  17. // o If this code is shipped in binary format the accompanying documentation
  18. //   should state that "this software is based, in part, on the work of
  19. //   Colosseum Builders, Inc."
  20. //
  21.  
  22. //
  23. //  Title:  Sample Image Viewer/Format Conversion Application
  24. //
  25. //  Author:  John M. Miano miano@colosseumbuilders.com
  26. //
  27. //---------------------------------------------------------------------
  28. #include <vcl.h>
  29. #pragma hdrstop
  30.  
  31. #include "PngConfig.h"
  32. //---------------------------------------------------------------------
  33. #pragma resource "*.dfm"
  34. TPngConfiguration *PngConfiguration;
  35. //--------------------------------------------------------------------- 
  36. __fastcall TPngConfiguration::TPngConfiguration(TComponent* AOwner)
  37.     : TForm(AOwner)
  38. {
  39. }
  40. //---------------------------------------------------------------------
  41. int TPngConfiguration::ShowModal (PngEncoder &pe)
  42. {
  43.   encoder = &pe ;
  44.   return TForm::ShowModal () ;
  45. }
  46.  
  47. void __fastcall TPngConfiguration::FormCreate(TObject *Sender)
  48. {
  49.   CompressionLevel->ItemIndex = 2 ;
  50.   return ;  
  51. }
  52. //---------------------------------------------------------------------------
  53.  
  54. void __fastcall TPngConfiguration::OKBtnClick(TObject *Sender)
  55. {
  56.   int blocksize ;
  57.   try
  58.   {
  59.     BlockSize->Text = BlockSize->Text.Trim () ;
  60.     blocksize = BlockSize->Text.ToInt () ;
  61.   }
  62.   catch (...)
  63.   {
  64.     ModalResult = mrNone ;
  65.     throw Exception ("Invalid Block Size") ;
  66.   }
  67.   if (blocksize < 1 || blocksize > 512000)
  68.   {
  69.     ModalResult = mrNone ;
  70.     throw Exception ("Invalid Block Size") ;
  71.   }
  72.  
  73.   encoder->SetBlockSize (blocksize) ;
  74.   encoder->SetUseFilters (UseFilters->Checked) ;
  75.   encoder->SetTitle (Title->Text.c_str ()) ;
  76.   encoder->SetAuthor (Author->Text.c_str ()) ;
  77.   encoder->SetDescription (Description->Text.c_str ()) ;
  78.   encoder->SetSource (Source->Text.c_str ()) ;
  79.   encoder->SetComment (Comment->Text.c_str ()) ;
  80.   return ;
  81. }
  82. //---------------------------------------------------------------------------
  83.  
  84.