Skip to content

Commit 3ea081e

Browse files
authored
Merge pull request #52 from rok4/develop
Release 2.0.5
2 parents d7fc822 + 3ca7ffa commit 3ea081e

File tree

6 files changed

+60
-46
lines changed

6 files changed

+60
-46
lines changed

.github/workflows/build-and-release.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
fail-fast: true
4040
matrix:
4141
include:
42-
- os: ubuntu-20.04
4342
- os: ubuntu-22.04
4443

4544
runs-on: ${{ matrix.os }}
@@ -69,7 +68,7 @@ jobs:
6968
make package
7069
7170
- name: Run unit tests
72-
if: "matrix.os == 'ubuntu-20.04'"
71+
if: "matrix.os == 'ubuntu-22.04'"
7372
run: |
7473
cd build
7574
make test
@@ -82,7 +81,7 @@ jobs:
8281
release-tag: ${{ github.ref_name }}
8382

8483
- name: Build documentation
85-
if: "matrix.os == 'ubuntu-20.04'"
84+
if: "matrix.os == 'ubuntu-22.04'"
8685
run: |
8786
cd build
8887
make doc
@@ -108,7 +107,7 @@ jobs:
108107
run: pip install -r docs/requirements.txt
109108

110109
- name: Publish documentation
111-
if: "matrix.os == 'ubuntu-20.04'"
110+
if: "matrix.os == 'ubuntu-22.04'"
112111
run: |
113112
git config user.name github-actions
114113
git config user.email github-actions@github.com

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2.0.5
2+
3+
### [Fixed]
4+
5+
* `LibtiffImage` : Gestion des tiff jpeg de photometrie YCbCr avec les tiffs palettes dans le _getline (élargissement du test)
6+
7+
## 2.0.4
8+
9+
### [Fixed]
10+
11+
* `Merge` : correction du nombre de méthode
12+
113
## 2.0.3
214

315
### [Added]

include/rok4/image/MergeImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ enum eMergeType {
8080
* \~french \brief Nombre de méthodes disponibles
8181
* \~english \brief Number of available merge methods
8282
*/
83-
const int mergetype_size = 6;
83+
const int mergetype_size = 5;
8484

8585
/**
8686
* \~french \brief Conversion d'une chaîne de caractères vers une méthode de fusion de l'énumération

src/image/MergeImage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,24 @@ int MergeMask::get_line ( float* buffer, int line ) {
220220

221221
namespace Merge {
222222

223-
const char *mergeType_name[] = {
223+
const char *mergetype_names[] = {
224224
"UNKNOWN",
225225
"NORMAL",
226226
"MULTIPLY",
227227
"ALPHATOP",
228228
"TOP"
229229
};
230230

231-
eMergeType from_string ( std::string strMergeMethod ) {
231+
eMergeType from_string ( std::string str_merge_method ) {
232232
int i;
233-
for ( i = mergetype_size; i ; --i ) {
234-
if ( strMergeMethod.compare ( mergeType_name[i] ) == 0 )
233+
for ( i = mergetype_size - 1; i ; --i ) {
234+
if ( str_merge_method.compare ( mergetype_names[i] ) == 0 )
235235
break;
236236
}
237237
return static_cast<eMergeType> ( i );
238238
}
239239

240240
std::string to_string ( eMergeType merge_method ) {
241-
return std::string ( mergeType_name[merge_method] );
241+
return std::string ( mergetype_names[merge_method] );
242242
}
243243
}

src/image/file/LibtiffImage.cpp

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ LibtiffImage* LibtiffImage::create_to_read ( std::string filename, BoundingBox<
190190
int width=0, height=0, channels=0, planarconfig=0, bitspersample=0, sf=0, ph=0, comp=0, rowsperstrip=0;
191191
bool tiled = false, palette = false;
192192
TIFF* tif = TIFFOpen ( filename.c_str(), "r" );
193-
194-
193+
194+
195195
/************** RECUPERATION DES INFORMATIONS **************/
196196

197197
if ( tif == NULL ) {
198198
BOOST_LOG_TRIVIAL(error) << "Unable to open TIFF (to read) " << filename ;
199199
return NULL;
200200
}
201-
201+
202202
if ( TIFFGetField ( tif, TIFFTAG_IMAGEWIDTH, &width ) < 1 ) {
203203
BOOST_LOG_TRIVIAL(error) << "Unable to read pixel width for file " << filename ;
204204
TIFFClose ( tif );
@@ -256,8 +256,8 @@ LibtiffImage* LibtiffImage::create_to_read ( std::string filename, BoundingBox<
256256
TIFFClose ( tif );
257257
return NULL;
258258
}
259-
260-
if (to_rok4_photometric ( ph ) == Photometric::PALETTE) {
259+
260+
if (to_rok4_photometric ( ph ) == Photometric::PALETTE) {
261261
palette = true;
262262
}
263263

@@ -294,7 +294,7 @@ LibtiffImage* LibtiffImage::create_to_read ( std::string filename, BoundingBox<
294294
TIFFClose ( tif );
295295
return NULL;
296296
}
297-
297+
298298
/********************** CONTROLES **************************/
299299

300300
if ( to_rok4_sampleformat ( sf, bitspersample ) == SampleFormat::UNKNOWN ) {
@@ -315,7 +315,7 @@ LibtiffImage* LibtiffImage::create_to_read ( std::string filename, BoundingBox<
315315
resx = 1.;
316316
resy = 1.;
317317
}
318-
318+
319319
/******************** CRÉATION DE L'OBJET ******************/
320320

321321
return new LibtiffImage (
@@ -343,12 +343,12 @@ LibtiffImage* LibtiffImage::create_to_write (
343343
BOOST_LOG_TRIVIAL(error) << "One dimension is not valid for the output image " << filename << " : " << width << ", " << height ;
344344
return NULL;
345345
}
346-
346+
347347
if ( channels <= 0 ) {
348348
BOOST_LOG_TRIVIAL(error) << "Number of samples per pixel is not valid for the output image " << filename << " : " << channels ;
349349
return NULL;
350350
}
351-
351+
352352
if ( resx > 0 && resy > 0 ) {
353353
// Vérification de la cohérence entre les résolutions et bbox fournies et les dimensions (en pixel) de l'image
354354
// Arrondi a la valeur entiere la plus proche
@@ -470,9 +470,9 @@ LibtiffImage::LibtiffImage (
470470
),
471471

472472
tif ( tif ), rowsperstrip ( rowsperstrip ), tiled (tiled), palette (palette) {
473-
473+
474474
// Ce constructeur permet de déterminer si la conversion de 1 à 8 bits est nécessaire, et de savoir si 0 est blanc ou noir
475-
475+
476476
if ( bps == 1 ) {
477477
// On fera la conversion en entiers sur 8 bits à la volée.
478478
// Cette image sera comme une image sur 8 bits.
@@ -501,7 +501,7 @@ LibtiffImage::LibtiffImage (
501501
current_strip = -1;
502502
int stripSize = width*rowsperstrip*pixel_size;
503503
strip_buffer = new uint8_t[stripSize];
504-
504+
505505
if (bit_to_byte) {
506506
// On a besoin d'un buffer supplémentaire pour faire la conversion à la volée à la lecture
507507
bit_to_byte_buffer = new uint8_t[stripSize];
@@ -516,7 +516,7 @@ LibtiffImage::LibtiffImage (
516516
FileImage ( width, height, resx, resy, channels, bbox, name, sampleformat, photometric, compression, extra_sample_type ),
517517

518518
tif ( tif ), rowsperstrip ( rowsperstrip ) {
519-
519+
520520
bit_to_byte = 0;
521521

522522
current_strip = -1;
@@ -530,9 +530,9 @@ LibtiffImage::LibtiffImage (
530530
template<typename T>
531531
int LibtiffImage::_getline ( T* buffer, int line ) {
532532
// buffer doit déjà être alloué, et assez grand, en tenant compte de la conversion
533-
533+
534534
if ( line / rowsperstrip != current_strip ) {
535-
535+
536536
// Les données n'ont pas encore été lue depuis l'image (strip pas en mémoire).
537537
current_strip = line / rowsperstrip;
538538

@@ -559,7 +559,8 @@ int LibtiffImage::_getline ( T* buffer, int line ) {
559559

560560
for (int t = 0; t < tilenumber_widthwise; t++) {
561561

562-
if (palette) {
562+
// Si l'image a une photometrie Palette ou bien YCBCR --> TIFFReadRGBATile
563+
if (palette || photometric == Photometric::YCBCR) {
563564
uint32* palette_buffer = new uint32[width * rowsperstrip];
564565

565566
size = TIFFReadRGBATile(tif, t * tile_width, current_strip * tile_height, palette_buffer );
@@ -604,7 +605,8 @@ int LibtiffImage::_getline ( T* buffer, int line ) {
604605

605606
_TIFFfree(tile_buf);
606607
} else {
607-
if (palette) {
608+
// Si l'image a une photometrie Palette ou bien YCBCR --> TIFFReadRGBAStrip
609+
if (palette || photometric == Photometric::YCBCR) {
608610
uint32* palette_buffer = new uint32[width * rowsperstrip];
609611
size = TIFFReadRGBAStrip ( tif, line, palette_buffer);
610612
if ( size == 0 ) {
@@ -625,7 +627,7 @@ int LibtiffImage::_getline ( T* buffer, int line ) {
625627
if (line / rowsperstrip == (height - 1) / rowsperstrip) {
626628
rows_count = height % rowsperstrip;
627629
}
628-
630+
629631
for (int l = 0; l < rows_count; l++) {
630632
for (int i = 0; i < width; i++) {
631633
memcpy ( strip_buffer + (width * l + i) * pixel_size, palette_buffer + (rows_count - 1 - l) * width + i, 3 );
@@ -641,19 +643,19 @@ int LibtiffImage::_getline ( T* buffer, int line ) {
641643
}
642644
}
643645
}
644-
646+
645647
if (bit_to_byte == 1) {
646648
OneBitConverter::minwhiteToGray(bit_to_byte_buffer, strip_buffer, size);
647649
} else if (bit_to_byte == 2) {
648650
OneBitConverter::minblackToGray(bit_to_byte_buffer, strip_buffer, size);
649651
}
650652
}
651-
653+
652654

653655
T buffertmp[width * channels];
654656

655657
/************* SI CONVERSION 1 bit -> 8 bits **************/
656-
658+
657659
if (bit_to_byte) {
658660
memcpy ( buffertmp, bit_to_byte_buffer + ( line%rowsperstrip ) * width * pixel_size, width * pixel_size );
659661
} else {
@@ -672,7 +674,7 @@ int LibtiffImage::_getline ( T* buffer, int line ) {
672674
memcpy(buffer, buffertmp, pixel_size * width);
673675
}
674676

675-
677+
676678
return width * get_channels();
677679
}
678680

@@ -698,7 +700,7 @@ int LibtiffImage::get_line ( uint8_t* buffer, int line ) {
698700
}
699701

700702
int LibtiffImage::get_line ( uint16_t* buffer, int line ) {
701-
703+
702704
if ( sample_format == SampleFormat::UINT8 ) {
703705
// On veut la ligne en entier 16 bits mais l'image lue est sur 8 bits : on convertit
704706
uint8_t* buffer_t = new uint8_t[width * get_channels()];
@@ -707,7 +709,7 @@ int LibtiffImage::get_line ( uint16_t* buffer, int line ) {
707709
delete [] buffer_t;
708710
return width * get_channels();
709711
} else if ( sample_format == SampleFormat::UINT16 ) { // uint16
710-
return _getline ( buffer,line );
712+
return _getline ( buffer,line );
711713
} else if ( sample_format == SampleFormat::FLOAT32 ) { // float
712714
/* On ne convertit pas les nombres flottants en entier sur 16 bits (aucun intérêt)
713715
* On va copier le buffer flottant sur le buffer entier 16 bits, de même taille en octet (2 fois plus grand en "nombre de cases")*/
@@ -733,7 +735,7 @@ int LibtiffImage::get_line ( float* buffer, int line ) {
733735
_getline ( buffer_t,line );
734736
convert ( buffer, buffer_t, width * get_channels() );
735737
delete [] buffer_t;
736-
return width * get_channels();
738+
return width * get_channels();
737739
} else if ( sample_format == SampleFormat::FLOAT32 ) { // float
738740
return _getline ( buffer, line );
739741
}
@@ -798,7 +800,7 @@ int LibtiffImage::write_image ( Image* pIn ) {
798800
}
799801

800802
int LibtiffImage::write_image ( uint8_t* buffer) {
801-
803+
802804
// Si l'image à écrire n'a pas des canaux en entiers sur 8 bits, on sort en erreur
803805

804806
// Ecriture de l'image
@@ -813,14 +815,14 @@ int LibtiffImage::write_image ( uint8_t* buffer) {
813815
} else {
814816
BOOST_LOG_TRIVIAL(error) << "Image to write (from a buffer) has not 8-bit uint samples : " << filename;
815817
print();
816-
return -1;
818+
return -1;
817819
}
818820

819821
return 0;
820822
}
821823

822824
int LibtiffImage::write_image ( uint16_t* buffer) {
823-
825+
824826
// Si l'image à écrire n'a pas des canaux en entiers sur 16 bits, on sort en erreur
825827

826828
// Ecriture de l'image
@@ -835,14 +837,14 @@ int LibtiffImage::write_image ( uint16_t* buffer) {
835837
} else {
836838
BOOST_LOG_TRIVIAL(error) << "Image to write (from a buffer) has not 16-bit uint samples : " << filename;
837839
print();
838-
return -1;
840+
return -1;
839841
}
840842

841843
return 0;
842844
}
843845

844846
int LibtiffImage::write_image ( float* buffer) {
845-
847+
846848
// Si l'image à écrire n'a pas des canaux en flottant sur 32 bits, on sort en erreur
847849

848850
if ( sample_format == SampleFormat::FLOAT32 ) {
@@ -874,10 +876,10 @@ int LibtiffImage::write_line ( uint8_t* buffer, int line) {
874876
} else {
875877
BOOST_LOG_TRIVIAL(error) << "Image to write (line by line) has not 8-bit uint samples : " << filename;
876878
print();
877-
return -1;
879+
return -1;
878880
}
879-
880-
881+
882+
881883
return 0;
882884
}
883885

@@ -894,15 +896,15 @@ int LibtiffImage::write_line ( uint16_t* buffer, int line) {
894896
} else {
895897
BOOST_LOG_TRIVIAL(error) << "Image to write (line by line) has not 16-bit uint samples : " << filename;
896898
print();
897-
return -1;
899+
return -1;
898900
}
899901

900902
return 0;
901903
}
902904

903905
int LibtiffImage::write_line ( float* buffer, int line) {
904906
// Si l'image à écrire n'a pas des canaux en flottant sur 32 bits, on sort en erreur
905-
907+
906908
if ( sample_format == SampleFormat::FLOAT32 ) {
907909
if ( TIFFWriteScanline ( tif, buffer, line, 0 ) < 0 ) {
908910
BOOST_LOG_TRIVIAL(error) << "Cannot write file " << TIFFFileName ( tif ) << ", line " << line ;
@@ -916,4 +918,3 @@ int LibtiffImage::write_line ( float* buffer, int line) {
916918

917919
return 0;
918920
}
919-

src/style/Style.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ void Style::add_node_wmts(ptree& parent, bool default_style) {
280280
ptree& node = parent.add("Style", "");
281281
if ( default_style ) {
282282
node.add("<xmlattr>.isDefault", "true");
283+
} else {
284+
node.add("<xmlattr>.isDefault", "false");
283285
}
284286

285287
for (std::string t : titles) {

0 commit comments

Comments
 (0)