/src/canvas/win32/ftk_bitmap_factory_win32.cpp

http://ftk.googlecode.com/ · C++ · 89 lines · 45 code · 15 blank · 29 comment · 8 complexity · 8a894a4cc93b62bb04c4dfea5b45687d MD5 · raw file

  1. /*
  2. * File: ftk_bitmap_factory.c
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief: bitmap factory.
  5. *
  6. * Copyright (c) 2009 - 2010 Li XianJing <xianjimli@hotmail.com>
  7. *
  8. * Licensed under the Academic Free License version 2.1
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /*
  25. * History:
  26. * ================================================================
  27. * 2009-10-03 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #include "ftk_log.h"
  31. #include "ftk_allocator.h"
  32. #include "ftk_bitmap_factory.h"
  33. #ifdef VC6
  34. #define ULONG_PTR unsigned long*
  35. #endif
  36. #include <windows.h>
  37. #include <gdiplus.h>
  38. #include "ftk_win32.h"
  39. struct _FtkBitmapFactory
  40. {
  41. int unused;
  42. };
  43. static FtkBitmap* load_win32 (const char *filename)
  44. {
  45. FtkBitmap* bitmap = NULL;
  46. WCHAR wfilename[MAX_PATH] = {0};
  47. mbstowcs(wfilename, filename, MAX_PATH);
  48. Bitmap* bitmap = Bitmap::FromFile(wfilename);
  49. return_val_if_fail(bitmap != NULL, NULL);
  50. if(bitmap->GetWidth() == 0 || bitmap->GetHeight() == 0)
  51. {
  52. delete bitmap;
  53. return NULL;
  54. }
  55. return ftk_bitmap_create_with_native(bitmap);
  56. }
  57. FtkBitmapFactory* ftk_bitmap_factory_create(void)
  58. {
  59. FtkBitmapFactory* thiz = (FtkBitmapFactory*)FTK_ZALLOC(sizeof(FtkBitmapFactory));
  60. return thiz;
  61. }
  62. FtkBitmap* ftk_bitmap_factory_load(FtkBitmapFactory* thiz, const char* filename)
  63. {
  64. return_val_if_fail(thiz != NULL && filename != NULL, NULL);
  65. return load_win32(filename);
  66. }
  67. Ret ftk_bitmap_factory_add_decoder(FtkBitmapFactory* thiz, FtkImageDecoder* decoder)
  68. {
  69. return RET_OK;
  70. }
  71. void ftk_bitmap_factory_destroy(FtkBitmapFactory* thiz)
  72. {
  73. return;
  74. }