1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-07 06:40:06 +00:00

- Add a patch from upstream's GIT repository, which fixes a bug in

vtkJPEGWriter when writing to memory.

- Bump PORTREVISION

  Original commit:
  http://vtk.org/gitweb?p=VTK.git;a=commit;h=e938db39c2bbd730a060cb0cf95fec52e15d281a
This commit is contained in:
Pietro Cerutti 2011-02-17 13:23:35 +00:00
parent f40891a549
commit df605311bd
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=269276
2 changed files with 47 additions and 1 deletions

View File

@ -8,7 +8,7 @@
PORTNAME= vtk
PORTVERSION= 5.6.1
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= math graphics
MASTER_SITES= http://www.vtk.org/files/release/${PORTVERSION:R}/ \
http://www.neuro.mcw.edu/Ports/distfiles/VTK5/

View File

@ -0,0 +1,46 @@
--- IO/vtkJPEGWriter.cxx
+++ IO/vtkJPEGWriter.cxx
@@ -129,7 +129,7 @@ void vtkJPEGWriter::Write()
this->InternalFileName = NULL;
}
-// these three routines are for wqriting into memory
+// these three routines are for writing into memory
extern "C"
{
void vtkJPEGWriteToMemoryInit(j_compress_ptr cinfo)
@@ -157,16 +157,20 @@ extern "C"
{
boolean vtkJPEGWriteToMemoryEmpty(j_compress_ptr cinfo)
{
+ // Even if (cinfo->dest->free_in_buffer != 0) we still need to write on the
+ // new array and not at (arraySize - nbFree)
vtkJPEGWriter *self = vtkJPEGWriter::SafeDownCast(
static_cast<vtkObject *>(cinfo->client_data));
if (self)
{
vtkUnsignedCharArray *uc = self->GetResult();
- // we must grow the array, we grow by 50% each time
+ // we must grow the array
int oldSize = uc->GetSize();
- uc->Resize(oldSize + oldSize/2);
+ uc->Resize(oldSize*1.5);
+ // Resize do grow the array but it is not the size we expect
+ int newSize = uc->GetSize();
cinfo->dest->next_output_byte = uc->GetPointer(oldSize);
- cinfo->dest->free_in_buffer = oldSize/2;
+ cinfo->dest->free_in_buffer = newSize - oldSize;
}
return TRUE;
}
@@ -182,8 +186,8 @@ extern "C"
{
vtkUnsignedCharArray *uc = self->GetResult();
// we must close the array
- vtkIdType oldSize = uc->GetSize();
- uc->SetNumberOfTuples(oldSize - static_cast<vtkIdType>(cinfo->dest->free_in_buffer));
+ int realSize = uc->GetSize() - cinfo->dest->free_in_buffer;
+ uc->SetNumberOfTuples(realSize);
}
}
}