You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.0 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "basicImageAux.h"
  2. /*
  3. SSID:DIRECT - JUQ0 : DSC - QX10
  4. Password : 9vQC7o5m
  5. */
  6. cortexImage *copy_image(cortexImage *p){
  7. cortexImage *RetVal, *RetVal2;
  8. RetVal = new cortexImage( p );
  9. RetVal->data = (float*)calloc(p->h*p->w*p->c, sizeof(float));
  10. if( RetVal->data != NULL ) {
  11. RetVal->h = p->h;
  12. RetVal->c = p->c;
  13. RetVal->w = p->w;
  14. memcpy( RetVal->data, p->data, p->h*p->w*p->c*sizeof(float));
  15. };
  16. RetVal2 = RetVal;
  17. return RetVal2;
  18. };
  19. cortexImageList **loadAlphabet(char *PathTemplate){
  20. cortexImageList **RetVal;
  21. RetVal = (cortexImageList**)calloc(8, sizeof(cortexImageList*));
  22. if (RetVal != NULL) {
  23. int i, j;
  24. for (j = 0; j < 8; ++j){
  25. RetVal[j] = new cortexImageList();
  26. for( i = 32; i < 127; ++i ){
  27. char buff[256];
  28. cortexImage *tVal;
  29. sprintf(buff, ((PathTemplate == NULL) ? "data/labels/%d_%d.png" : PathTemplate), i, j);
  30. tVal = new cortexImage();
  31. tVal->fillFromFile( buff, 0, 0, 3 );
  32. RetVal[j]->push_back(tVal);
  33. };
  34. };
  35. };
  36. return RetVal;
  37. };
  38. cortexImage *createLabel(cortexImageList *Alphabet, char *string, int size){
  39. cortexImage *RetVal=NULL;
  40. if( size > 7 ) size = 7;
  41. while( *string != (char)0 ){
  42. cortexImage *tVal = Alphabet[size][((int)*string) - 32];
  43. RetVal = tileImages(tVal, RetVal, -size - 1 + (size + 1) / 2);
  44. delete(tVal);
  45. tVal = RetVal;
  46. ++string;
  47. };
  48. RetVal->drawBoxWEX(0, 0, RetVal->w, RetVal->h, (int)(RetVal->h*.25), 0.f, 1.f, 0.f);
  49. return RetVal;
  50. };
  51. cortexImage *tileImages(cortexImage *a, cortexImage *b, int dx){
  52. cortexImage *RetVal = NULL;
  53. if( a!= NULL && b!=NULL )
  54. if( a->w == 0 ){
  55. RetVal = new cortexImage(b);
  56. } else if( b->w == 0 ){
  57. RetVal = new cortexImage(a);
  58. } else {
  59. RetVal = new cortexImage();
  60. if (RetVal != NULL){
  61. RetVal->makeEmpty(a->w + b->w + dx, (a->h > b->h) ? a->h : b->h, (a->c > b->c) ? a->c : b->c);
  62. //RetVal->fill_cpu(RetVal->w*RetVal->h*RetVal->c, 1, RetVal->data, 1);//??
  63. RetVal->embed( a, 0, 0 );
  64. RetVal->composite( b, a->w + dx, 0 );
  65. };
  66. };
  67. return RetVal;
  68. };