view release on metacpan or search on metacpan
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
typedef std::list<BlockTypeS *>::iterator BlockListIterator;
// ----------------------------------------------------------
FI_STRUCT (MULTIBITMAPHEADER) {
PluginNode *node;
FREE_IMAGE_FORMAT fif;
FreeImageIO *io;
fi_handle handle;
CacheFile *m_cachefile;
std::map<FIBITMAP *, int> locked_pages;
BOOL changed;
int page_count;
BlockList m_blocks;
char *m_filename;
BOOL read_only;
FREE_IMAGE_FORMAT cache_fif;
int load_flags;
};
// =====================================================================
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
// flush and dispose the cache
if (header->m_cachefile) {
header->m_cachefile->close();
delete header->m_cachefile;
}
// delete the last open bitmaps
while (!header->locked_pages.empty()) {
FreeImage_Unload(header->locked_pages.begin()->first);
header->locked_pages.erase(header->locked_pages.begin()->first);
}
// get rid of the IO structure
delete header->io;
// delete the filename
if(header->m_filename) {
delete[] header->m_filename;
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
}
return header->page_count;
}
return 0;
}
static BlockReference*
FreeImage_SavePageToBlock(MULTIBITMAPHEADER *header, FIBITMAP *data) {
if (header->read_only || !header->locked_pages.empty())
return NULL;
DWORD compressed_size = 0;
BYTE *compressed_data = NULL;
// compress the bitmap data
// open a memory handle
FIMEMORY *hmem = FreeImage_OpenMemory();
if(hmem==NULL) return NULL;
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
header->changed = TRUE;
header->page_count = -1;
}
void DLL_CALLCONV
FreeImage_DeletePage(FIMULTIBITMAP *bitmap, int page) {
if (bitmap) {
MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);
if ((!header->read_only) && (header->locked_pages.empty())) {
if (FreeImage_GetPageCount(bitmap) > 1) {
BlockListIterator i = FreeImage_FindBlock(bitmap, page);
if (i != header->m_blocks.end()) {
switch((*i)->m_type) {
case BLOCK_CONTINUEUS :
delete *i;
header->m_blocks.erase(i);
break;
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
}
}
}
FIBITMAP * DLL_CALLCONV
FreeImage_LockPage(FIMULTIBITMAP *bitmap, int page) {
if (bitmap) {
MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);
// only lock if the page wasn't locked before...
for (std::map<FIBITMAP *, int>::iterator i = header->locked_pages.begin(); i != header->locked_pages.end(); ++i) {
if (i->second == page) {
return NULL;
}
}
// open the bitmap
header->io->seek_proc(header->handle, 0, SEEK_SET);
void *data = FreeImage_Open(header->node, header->io, header->handle, TRUE);
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
if (data != NULL) {
FIBITMAP *dib = (header->node->m_plugin->load_proc != NULL) ? header->node->m_plugin->load_proc(header->io, header->handle, page, header->load_flags, data) : NULL;
// close the file
FreeImage_Close(header->node, header->io, header->handle, data);
// if there was still another bitmap open, get rid of it
if (dib) {
header->locked_pages[dib] = page;
return dib;
}
return NULL;
}
}
return NULL;
}
void DLL_CALLCONV
FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *page, BOOL changed) {
if ((bitmap) && (page)) {
MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);
// find out if the page we try to unlock is actually locked...
if (header->locked_pages.find(page) != header->locked_pages.end()) {
// store the bitmap compressed in the cache for later writing
if (changed && !header->read_only) {
header->changed = TRUE;
// cut loose the block from the rest
BlockListIterator i = FreeImage_FindBlock(bitmap, header->locked_pages[page]);
// compress the data
DWORD compressed_size = 0;
BYTE *compressed_data = NULL;
// open a memory handle
FIMEMORY *hmem = FreeImage_OpenMemory();
// save the page to memory
FreeImage_SaveToMemory(header->cache_fif, page, hmem, 0);
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
break;
}
}
// get rid of the compressed data
FreeImage_CloseMemory(hmem);
}
// reset the locked page so that another page can be locked
FreeImage_Unload(page);
header->locked_pages.erase(page);
}
}
}
BOOL DLL_CALLCONV
FreeImage_MovePage(FIMULTIBITMAP *bitmap, int target, int source) {
if (bitmap) {
MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);
if ((!header->read_only) && (header->locked_pages.empty())) {
if ((target != source) && ((target >= 0) && (target < FreeImage_GetPageCount(bitmap))) && ((source >= 0) && (source < FreeImage_GetPageCount(bitmap)))) {
BlockListIterator block_source = FreeImage_FindBlock(bitmap, target);
BlockListIterator block_target = FreeImage_FindBlock(bitmap, source);
header->m_blocks.insert(block_target, *block_source);
header->m_blocks.erase(block_source);
header->changed = TRUE;
return TRUE;
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
return FALSE;
}
BOOL DLL_CALLCONV
FreeImage_GetLockedPageNumbers(FIMULTIBITMAP *bitmap, int *pages, int *count) {
if ((bitmap) && (count)) {
MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);
if ((pages == NULL) || (*count == 0)) {
*count = (int)header->locked_pages.size();
} else {
int c = 0;
for (std::map<FIBITMAP *, int>::iterator i = header->locked_pages.begin(); i != header->locked_pages.end(); ++i) {
pages[c] = i->second;
c++;
if (c == *count)
break;
}
}
return TRUE;
src/Source/LibRawLite/dcraw/dcraw.c view on Meta::CPAN
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
//@end DEFINES
#if defined(DJGPP) || defined(__MINGW32__)
#define fseeko fseek
#define ftello ftell
#else
#define fgetc getc_unlocked
#endif
//@out DEFINES
#ifdef __CYGWIN__
#include <io.h>
#endif
#ifdef WIN32
#include <sys/utime.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#define snprintf _snprintf
src/Source/LibRawLite/libraw/libraw_datastream.h view on Meta::CPAN
virtual const char *fname();
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
virtual const wchar_t* wfname();
virtual int subfile_open(const wchar_t *fn);
#endif
virtual int subfile_open(const char *fn);
virtual void subfile_close();
virtual int get_char()
{
#ifndef WIN32
return substream?substream->get_char():getc_unlocked(f);
#else
return substream?substream->get_char():fgetc(f);
#endif
}
protected:
FILE *f,*sav;
std::string filename;
INT64 _fsize;
#ifdef WIN32
src/Source/LibRawLite/src/libraw_cxx.cpp view on Meta::CPAN
}
#else
void LibRaw::fix_after_rawspeed(int)
{
}
#endif
void LibRaw::clearCancelFlag()
{
#ifdef WIN32
InterlockedExchange(&_exitflag, 0);
#else
__sync_fetch_and_and(&_exitflag, 0);
#endif
#ifdef RAWSPEED_FASTEXIT
if (_rawspeed_decoder)
{
RawDecoder *d = static_cast<RawDecoder*>(_rawspeed_decoder);
d->resumeProcessing();
}
#endif
}
void LibRaw::setCancelFlag()
{
#ifdef WIN32
InterlockedExchange(&_exitflag,1);
#else
__sync_fetch_and_add(&_exitflag,1);
#endif
#ifdef RAWSPEED_FASTEXIT
if(_rawspeed_decoder)
{
RawDecoder *d = static_cast<RawDecoder*>(_rawspeed_decoder);
d->cancelProcessing();
}
#endif
}
void LibRaw::checkCancel()
{
#ifdef WIN32
if(InterlockedExchange(&_exitflag,0))
throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;
#else
if( __sync_fetch_and_and(&_exitflag,0))
throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;
#endif
}
int LibRaw::unpack(void)
{
CHECK_ORDER_HIGH(LIBRAW_PROGRESS_LOAD_RAW);
src/Source/OpenEXR/IlmImf/ImfDwaCompressor.cpp view on Meta::CPAN
{
dst[i] = dst[0];
}
#endif /* IMF_HAVE_SSE2 */
} // blockIsConstant
} // comp
} // blockx
//
// At this point, we have half-float nonlinear value blocked
// in rowBlock[][]. We need to unblock the data, transfer
// back to linear, and write the results in the _rowPtrs[].
//
// There is a fast-path for aligned rows, which helps
// things a little. Since this fast path is only valid
// for full 8-element wide blocks, the partial x blocks
// are broken into a separate loop below.
//
// At the moment, the fast path requires:
// * sse support
src/Source/OpenEXR/IlmThread/IlmThreadMutex.h view on Meta::CPAN
friend class Lock;
};
class ILMTHREAD_EXPORT Lock
{
public:
Lock (const Mutex& m, bool autoLock = true):
_mutex (m),
_locked (false)
{
if (autoLock)
{
_mutex.lock();
_locked = true;
}
}
~Lock ()
{
if (_locked)
_mutex.unlock();
}
void acquire ()
{
_mutex.lock();
_locked = true;
}
void release ()
{
_mutex.unlock();
_locked = false;
}
bool locked ()
{
return _locked;
}
private:
const Mutex & _mutex;
bool _locked;
};
ILMTHREAD_INTERNAL_NAMESPACE_HEADER_EXIT
#endif // INCLUDED_ILM_THREAD_MUTEX_H