SkinFile.cpp
上传用户:lusi_8715
上传日期:2007-01-08
资源大小:199k
文件大小:2k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /**************************************************************************************
  2.  *                                                                                    *
  3.  * This application contains code from OpenDivX and is released as a "Larger Work"    *
  4.  * under that license. Consistant with that license, this application is released     *
  5.  * under the GNU General Public License.                                              *
  6.  *                                                                                    *
  7.  * The OpenDivX license can be found at: http://www.projectmayo.com/opendivx/docs.php *
  8.  * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html                      *
  9.  *                                                                                    *
  10.  * Copyright (c) 2001 - Project Mayo                                                  *
  11.  *                                                                                    *
  12.  * Authors: Damien Chavarria <adrc at projectmayo.com>                                *
  13.  *                                                                                    *
  14.  **************************************************************************************/
  15. #include "SkinFile.h"
  16. /*
  17.  * Skin config file class
  18.  */
  19. SkinFile::SkinFile(char *directory) {
  20. this->configFile = NULL;
  21. if(directory != NULL) {
  22. char *filename;
  23. filename = (char *) malloc(strlen(directory) + 12);
  24. strcpy(filename, directory);
  25. this->configFile = fopen(strcat(filename, "\config.txt"), "rt");
  26. free(filename);
  27. }
  28. }
  29. SkinFile::~SkinFile() {
  30. }
  31. int SkinFile::getColor(char *section) {
  32. if(this->configFile) {
  33. int r = 0, g = 0, b = 0;
  34. char *buffer;
  35. buffer    = (char *) malloc(strlen(section) + 6);
  36. buffer[0] = '[';
  37. strcat(buffer + 1, section);
  38. strcat(buffer, "]n");
  39. fscanf(this->configFile, buffer);
  40. fread(buffer, 1, strlen(section) + 2, configFile);
  41. fscanf(this->configFile, "%d, %d, %d", &r, &g, &b);
  42. //free(buffer);
  43. return r + 256*g + 65536*b;
  44. }
  45. return 0;
  46. }
  47. void SkinFile::Close() {
  48. if(this->configFile) {
  49. fclose(this->configFile);
  50. }
  51. }