/** ~ComplxFrame * * Destructor */ ComplxFrame::~ComplxFrame() { complxframe = NULL; Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_COMPLETED, wxThreadEventHandler(ComplxFrame::OnRunComplete)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_UPDATE, wxThreadEventHandler(ComplxFrame::OnRunUpdate)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_IO, wxThreadEventHandler(ComplxFrame::OnIo)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_NOIO, wxThreadEventHandler(ComplxFrame::OnNoIo)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_OUTPUT, wxThreadEventHandler(ComplxFrame::OnOutput)); { wxCriticalSectionLocker enter(threadCS); if (thread != NULL) { thread->Delete(); thread = NULL; } } DestroyImages(); Destroy(); }
void CPet::SetImages( HICON* hIconTable, int nIcons ) { //delete current images DestroyImages(); //we can't have 0 images if( nIcons <= 0 ) { nIcons = 1; #ifdef DEBUG OutputDebugString( "WARNING: CPet::SetImages() passed 0 as nIcons\n" ); #endif } //FIXME: it might be possible to use CopyImage() passing it the *scaled* width and height //in combination with the LR_COPYFROMRESOURCE. This might fix the non-32x32 icon problem //allocate icon table and clear all entries m_hIcons = new HICON[nIcons]; for( int i = 0; i < nIcons; i++ ) m_hIcons[i] = CopyIcon(hIconTable[i]); //store icon table size and set last drawn icon index m_nIcons = nIcons; m_nLastIcon = -1; //get size of first icon ICONINFO ii; GetIconInfo( m_hIcons[0], &ii ); BITMAP bm; GetObject( ii.hbmMask, sizeof(BITMAP), &bm ); DeleteObject( ii.hbmMask ); DeleteObject( ii.hbmColor ); //calculate scaled size m_sizeImage.cx = int( bm.bmWidth * m_fScale ); m_sizeImage.cy = int( bm.bmHeight * m_fScale ); }
/** ~ComplxFrame * * Destructor */ ComplxFrame::~ComplxFrame() { auto* config = wxConfigBase::Get(); int width, height; GetSize(&width, &height); config->Write("/appwidth", wxString::Format("%d", width)); config->Write("/appheight", wxString::Format("%d", height)); const auto& column_sizes = memory->GetColSizes(); std::stringstream oss; for (unsigned int i = 0; i < MemorySize; i++) { oss << column_sizes.GetSize(i) << ","; } wxString sizes = oss.str(); config->Write("/columnsizes", sizes); complxframe = NULL; Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_COMPLETED, wxThreadEventHandler(ComplxFrame::OnRunComplete)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_IO, wxThreadEventHandler(ComplxFrame::OnIo)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_NOIO, wxThreadEventHandler(ComplxFrame::OnNoIo)); Disconnect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_OUTPUT, wxThreadEventHandler(ComplxFrame::OnOutput)); { wxCriticalSectionLocker enter(threadCS); if (thread != NULL) { thread->Delete(); thread = NULL; } } DestroyImages(); Destroy(); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d Y U V I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadYUVImage reads an image with digital YUV (CCIR 601 4:1:1) bytes % and returns it. It allocates the memory necessary for the new Image % structure and returns a pointer to the new image. % % The format of the ReadYUVImage method is: % % Image *ReadYUVImage(const ImageInfo *image_info) % % A description of each parameter follows: % % o image: Method ReadYUVImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or % if the image cannot be read. % % o image_info: Specifies a pointer to an ImageInfo structure. % % */ Export Image *ReadYUVImage(const ImageInfo *image_info) { Image *chroma_image, *image, *zoom_image; int count, y; register int i, x; register PixelPacket *q, *r; register unsigned char *p; unsigned char *scanline; unsigned int status; /* Allocate image structure. */ image=AllocateImage(image_info); if (image == (Image *) NULL) return((Image *) NULL); if ((image->columns == 0) || (image->rows == 0)) ReaderExit(OptionWarning,"Must specify image size",image); image->depth=8; if (image_info->interlace != PartitionInterlace) { /* Open image file. */ status=OpenBlob(image_info,image,ReadBinaryType); if (status == False) ReaderExit(FileOpenWarning,"Unable to open file",image); for (i=0; i < image->offset; i++) (void) ReadByte(image); } /* Allocate memory for a scanline. */ scanline=(unsigned char *) AllocateMemory(image->columns*sizeof(unsigned char)); if (scanline == (unsigned char *) NULL) ReaderExit(ResourceLimitWarning,"Memory allocation failed",image); do { /* Convert raster image to pixel packets. */ if (image_info->interlace == PartitionInterlace) { AppendImageFormat("Y",image->filename); status=OpenBlob(image_info,image,ReadBinaryType); if (status == False) ReaderExit(FileOpenWarning,"Unable to open file",image); } for (y=0; y < (int) image->rows; y++) { if ((y > 0) || (image->previous == (Image *) NULL)) (void) ReadBlob(image,image->columns,scanline); p=scanline; q=SetPixelCache(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; for (x=0; x < (int) image->columns; x++) { q->red=UpScale(*p++); q->green=0; q->blue=0; q++; } if (!SyncPixelCache(image)) break; if (image->previous == (Image *) NULL) ProgressMonitor(LoadImageText,y,image->rows); } if (image_info->interlace == PartitionInterlace) { CloseBlob(image); AppendImageFormat("U",image->filename); status=OpenBlob(image_info,image,ReadBinaryType); if (status == False) ReaderExit(FileOpenWarning,"Unable to open file",image); } chroma_image=CloneImage(image,image->columns/2,image->rows/2,True); if (chroma_image == (Image *) NULL) ReaderExit(ResourceLimitWarning,"Memory allocation failed",image); for (y=0; y < (int) chroma_image->rows; y++) { (void) ReadBlob(image,chroma_image->columns,scanline); p=scanline; q=SetPixelCache(chroma_image,0,y,chroma_image->columns,1); if (q == (PixelPacket *) NULL) break; for (x=0; x < (int) chroma_image->columns; x++) { q->red=0; q->green=UpScale(*p++); q->blue=0; q++; } if (!SyncPixelCache(chroma_image)) break; } if (image_info->interlace == PartitionInterlace) { CloseBlob(image); AppendImageFormat("V",image->filename); status=OpenBlob(image_info,image,ReadBinaryType); if (status == False) ReaderExit(FileOpenWarning,"Unable to open file",image); } for (y=0; y < (int) chroma_image->rows; y++) { (void) ReadBlob(image,chroma_image->columns,scanline); p=scanline; q=GetPixelCache(chroma_image,0,y,chroma_image->columns,1); if (q == (PixelPacket *) NULL) break; for (x=0; x < (int) chroma_image->columns; x++) { q->blue=UpScale(*p++); q++; } if (!SyncPixelCache(chroma_image)) break; } /* Scale image. */ chroma_image->orphan=True; zoom_image=SampleImage(chroma_image,image->columns,image->rows); DestroyImage(chroma_image); if (zoom_image == (Image *) NULL) ReaderExit(ResourceLimitWarning,"Memory allocation failed",image); for (y=0; y < (int) image->rows; y++) { q=GetPixelCache(image,0,y,image->columns,1); r=GetPixelCache(zoom_image,0,y,zoom_image->columns,1); if ((q == (PixelPacket *) NULL) || (r == (PixelPacket *) NULL)) break; for (x=0; x < (int) image->columns; x++) { q->green=r->green; q->blue=r->blue; r++; q++; } if (!SyncPixelCache(image)) break; } DestroyImage(zoom_image); TransformRGBImage(image,YCbCrColorspace); if (image_info->interlace == PartitionInterlace) (void) strcpy(image->filename,image_info->filename); /* Proceed to next image. */ if (image_info->subrange != 0) if (image->scene >= (image_info->subimage+image_info->subrange-1)) break; count=ReadBlob(image,image->columns,(char *) scanline); if (count > 0) { /* Allocate next image structure. */ AllocateNextImage(image_info,image); if (image->next == (Image *) NULL) { DestroyImages(image); return((Image *) NULL); } image=image->next; ProgressMonitor(LoadImagesText,TellBlob(image),image->filesize); } } while (count > 0); FreeMemory(scanline); while (image->previous != (Image *) NULL) image=image->previous; CloseBlob(image); return(image); }
CPet::~CPet() { //delete the images DestroyImages(); }