[vtkusers] JPEGImageWriter to memory (C++)

Andrew Higginson at.higginson at gmail.com
Sat Apr 23 08:45:00 EDT 2016


Fab it works!

I think I also had issues with trying to use the data directly, however
after copying it to a new location with memcpy everything worked.

Cheers :)

On Sat, 23 Apr 2016 at 12:25 David E DeMarle <dave.demarle at kitware.com>
wrote:

> Try:
> char *data = (char*)d->GetVoidPointer();
> size_t size = (size_t)(d->GetSize()*d->GetDataTypeSize());
>
>
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
> On Fri, Apr 22, 2016 at 7:11 PM, Andrew Higginson <at.higginson at gmail.com>
> wrote:
>
>> Hi all,
>>
>>
>> I am trying to use a vtkJPEGImageWriter to write a JPEG file to memory
>> (instead of writing to disk and then reading it again using fopen or
>> similar) in C++.
>>
>>
>> To do this I believe I need something like the following:
>>
>> ----
>> vtkSmartPointer<vtkJPEGWriter> writer =
>> vtkSmartPointer<vtkJPEGWriter>::New();
>> writer->SetWriteToMemory(true);
>> writer->SetInputData(...);
>> writer->Write();
>>
>> vtkUnsignedCharArray* d = writer->GetResult();
>> ----
>>
>>
>> However at this point I don't know how to extract what I need from the
>> vtkUnsignedCharArray. I would like the raw bytes and size, like so:
>>
>>
>> ----
>> char* data = d->...
>> size_t size = d->...
>> ----
>>
>>
>>
>> But I am not sure how to do this. Any help would be greatly appreciated :)
>>
>>
>> Thanks,
>> Andrew Higginson
>> --
>>
>> Andrew Higginson
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
> --

Andrew Higginson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160423/e2f9df77/attachment.html>


More information about the vtkusers mailing list