Экспертная система Delphi.int.ru

Сообщество программистов
Общение, помощь, обмен опытом

Логин:
Пароль:
Регистрация | Забыли пароль?

Delphi.int.ru Expert

Другие разделы портала

Переход к вопросу:

#   

Статистика за сегодня:  


Лучшие эксперты

Подробнее »



Вопрос # 6 329

Раздел: C++
/ вопрос открыт /

Здравствуйте, эксперты!
Пытаюсь разобраться в "распаковке и запаковке" jpeg-файлов, для дальнейшего внедрения на место НЗБ файла-контейнера, битов нужного мне ЦВЗ (цифровой водяной знак).
Нашел библиотеки для работы с jpeg-файлами, в частности закрепленный ниже модуль. В нем меня особо интересуют функция:

GLOBAL(void)
read_JPEG_file (char * filename, int quality)

Внимание вопрос: могу ли я использовать их, работая в visual studio С++ в том виде, в котором они есть? Или же придется переписывать под С++?

К вопросу прикреплён файл. Загрузить » (срок хранения: 60 дней с момента отправки вопроса)

Приложение:
  1. GLOBAL(void)
  2. write_JPEG_file (char * filename, int quality)
  3. {
  4.  
  5. struct jpeg_compress_struct cinfo;
  6.  
  7. struct jpeg_error_mgr jerr;
  8. /* More stuff */
  9. FILE * outfile; /* target file */
  10. JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
  11. int row_stride; /* physical row width in image buffer */
  12.  
  13. /* Step 1: allocate and initialize JPEG compression object */
  14.  
  15. /* We have to set up the error handler first, in case the initialization
  16. * step fails. (Unlikely, but it could happen if you are out of memory.)
  17. * This routine fills in the contents of struct jerr, and returns jerr's
  18. * address which we place into the link field in cinfo.
  19. */
  20. cinfo.err = jpeg_std_error(&jerr);
  21. /* Now we can initialize the JPEG compression object. */
  22. jpeg_create_compress(&cinfo);
  23.  
  24. /* Step 2: specify data destination (eg, a file) */
  25. /* Note: steps 2 and 3 can be done in either order. */
  26.  
  27. /* Here we use the library-supplied code to send compressed data to a
  28. * stdio stream. You can also write your own code to do something else.
  29. * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
  30. * requires it in order to write binary files.
  31. */
  32. if ((outfile = fopen(filename, "wb")) == NULL) {
  33. fprintf(stderr, "can't open %s\n", filename);
  34. exit(1);
  35. }
  36. jpeg_stdio_dest(&cinfo, outfile);
  37.  
  38. /* Step 3: set parameters for compression */
  39.  
  40. /* First we supply a description of the input image.
  41. * Four fields of the cinfo struct must be filled in:
  42. */
  43. cinfo.image_width = image_width; /* image width and height, in pixels */
  44. cinfo.image_height = image_height;
  45. cinfo.input_components = 3; /* # of color components per pixel */
  46. cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
  47. /* Now use the library's routine to set default compression parameters.
  48. * (You must set at least cinfo.in_color_space before calling this,
  49. * since the defaults depend on the source color space.)
  50. */
  51. jpeg_set_defaults(&cinfo);
  52. /* Now you can set any non-default parameters you wish to.
  53. * Here we just illustrate the use of quality (quantization table) scaling:
  54. */
  55. jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
  56.  
  57. /* Step 4: Start compressor */
  58.  
  59. /* TRUE ensures that we will write a complete interchange-JPEG file.
  60. * Pass TRUE unless you are very sure of what you're doing.
  61. */
  62. jpeg_start_compress(&cinfo, TRUE);
  63.  
  64. /* Step 5: while (scan lines remain to be written) */
  65. /* jpeg_write_scanlines(...); */
  66.  
  67. /* Here we use the library's state variable cinfo.next_scanline as the
  68. * loop counter, so that we don't have to keep track ourselves.
  69. * To keep things simple, we pass one scanline per call; you can pass
  70. * more if you wish, though.
  71. */
  72. row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */
  73.  
  74. while (cinfo.next_scanline < cinfo.image_height) {
  75. /* jpeg_write_scanlines expects an array of pointers to scanlines.
  76. * Here the array is only one element long, but you could pass
  77. * more than one scanline at a time if that's more convenient.
  78. */
  79. row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
  80. (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
  81. }
  82.  
  83. /* Step 6: Finish compression */
  84.  
  85. jpeg_finish_compress(&cinfo);
  86. /* After finish_compress, we can close the output file. */
  87. fclose(outfile);
  88.  
  89. /* Step 7: release JPEG compression object */
  90.  
  91. /* This is an important step since it will release a good deal of memory. */
  92. jpeg_destroy_compress(&cinfo);
  93.  
  94. /* And we're done! */
  95. }
  96.  


NeStor Вопрос ожидает решения (принимаются ответы, доступен мини-форум)

Вопрос задал: NeStor (статус: Посетитель)
Вопрос отправлен: 8 декабря 2012, 20:12
Состояние вопроса: открыт, ответов: 0.


Мини-форум вопроса

Всего сообщений: 1; последнее сообщение — 10 декабря 2012, 08:19; участников в обсуждении: 1.
min@y™

min@y™ (статус: Доктор наук), 10 декабря 2012, 08:19 [#1]:

Цитата (NeStor):

Внимание вопрос: могу ли я использовать их, работая в visual studio С++ в том виде, в котором они есть? Или же придется переписывать под С++?

Странный вопрос... Просто взять и попробовать религия не позволяет?
Делаю лабы и курсачи по Delphi и Turbo Pascal. За ПИВО! Пишите в личку, а лучше в аську. А ещё лучше - звоните в скайп!

Чтобы оставлять сообщения в мини-форумах, Вы должны авторизироваться на сайте.

Версия движка: 2.6+ (26.01.2011)
Текущее время: 22 февраля 2025, 11:48
Выполнено за 0.02 сек.