コード例 #1
0
// 2.
// Create the Video Digitizer (using GWorld Pixmap as target mamory)
void QuicktimeLiveImageStream::createVideoDigitizer()
{
    // #define videoDigitizerComponentType = 'vdig'
    ComponentDescription video_component_description;
    video_component_description.componentType         = 'vdig'; /* A unique 4-byte code indentifying the command set */
    video_component_description.componentSubType      = 0;      /* Particular flavor of this instance */
    video_component_description.componentManufacturer = 0;      /* Vendor indentification */
    video_component_description.componentFlags        = 0;      /* 8 each for Component,Type,SubType,Manuf/revision */
    video_component_description.componentFlagsMask    = 0;      /* Mask for specifying which flags to consider in search, zero during registration */
    long num_video_components = CountComponents (&video_component_description);
    OSG_DEBUG << " available Video DigitizerComponents : " << num_video_components << std::endl;
    if (num_video_components)
    {
        Component aComponent = 0;
        short     aDeviceID  = 0;
        do
        {
            ComponentDescription full_video_component_description = video_component_description;
            aComponent = FindNextComponent(aComponent, &full_video_component_description);
            if (aComponent && (aDeviceID == m_videoDeviceID))
            {
                OSG_DEBUG << "Component" << std::endl;
                OSErr                err;
                Handle compName = NewHandle(256);
                Handle compInfo = NewHandle(256);
                err = GetComponentInfo( aComponent, &full_video_component_description, compName,compInfo,0);
                OSG_DEBUG << "    Name: " << pstr_printable((StringPtr)*compName) << std::endl;
                OSG_DEBUG << "    Desc: " << pstr_printable((StringPtr)*compInfo) << std::endl;
                //Capabilities
                VideoDigitizerComponent component_instance = OpenComponent(aComponent);
                m_vdig = component_instance;
                //Setup
                // Onscreen
                // Check capability and setting of Sequence Grabber
                GDHandle origDevice;
                CGrafPtr origPort;
                GetGWorld (&origPort, &origDevice);
                VideoDigitizerError error;
                Rect                destinationBounds;
                destinationBounds.left   = 0;
                destinationBounds.top    = 0;
                destinationBounds.right  = m_videoRectWidth;
                destinationBounds.bottom = m_videoRectHeight;                    
                error = VDSetPlayThruDestination(m_vdig, m_pixmap, &destinationBounds, 0, 0);
                //error = VDSetPlayThruGlobalRect(m_vdig, (GrafPtr)origPort, &destinationBounds);
                if (error != noErr)
                {
                    OSG_FATAL << "VDSetPlayThruDestination : error" << std::endl;
                }
                print_video_component_capability(component_instance);
                break;
            }
            ++aDeviceID;
        }
        while (0 != aComponent);
     }
}
コード例 #2
0
ファイル: MailContainer.cpp プロジェクト: AmirAbrams/haiku
status_t
BMIMEMultipartMailContainer::RemoveComponent(int32 index)
{
	if (index >= CountComponents())
		return B_BAD_INDEX;

	delete (BMailComponent *)_components_in_code.RemoveItem(index);
	delete (message_part *)_components_in_raw.RemoveItem(index);

	return B_OK;
}
コード例 #3
0
BEmailMessage *
BEmailMessage::ForwardMessage(bool accountFromMail, bool includeAttachments)
{
	BString header = "------ Forwarded Message: ------\n";
	header << "To: " << To() << '\n';
	header << "From: " << From() << '\n';
	if (CC() != NULL) {
		// Can use CC rather than "Cc" since display only.
		header << "CC: " << CC() << '\n';
	}
	header << "Subject: " << Subject() << '\n';
	header << "Date: " << Date() << "\n\n";
	if (_text_body != NULL)
		header << _text_body->Text() << '\n';
	BEmailMessage *message = new BEmailMessage();
	message->SetBodyTextTo(header.String());

	// set the subject
	BString subject = Subject();
	if (subject.IFindFirst("fwd") == B_ERROR
		&& subject.IFindFirst("forward") == B_ERROR
		&& subject.FindFirst("FW") == B_ERROR)
		subject << " (fwd)";
	message->SetSubject(subject.String());

	if (includeAttachments) {
		for (int32 i = 0; i < CountComponents(); i++) {
			BMailComponent *cmpt = GetComponent(i);
			if (cmpt == _text_body || cmpt == NULL)
				continue;

			//---I am ashamed to have the written the code between here and the next comment
			// ... and you still managed to get it wrong ;-)), axeld.
			// we should really move this stuff into copy constructors
			// or something like that

			BMallocIO io;
			cmpt->RenderToRFC822(&io);
			BMailComponent *clone = cmpt->WhatIsThis();
			io.Seek(0, SEEK_SET);
			clone->SetToRFC822(&io, io.BufferLength(), true);
			message->AddComponent(clone);
		}
	}
	if (accountFromMail)
		message->SendViaAccountFrom(this);

	return message;
}
コード例 #4
0
ファイル: quicktime.c プロジェクト: MattHung/sage-graphics
//  SGSettingsDialog with the "Compression" panel removed
static OSErr MinimalSGSettingsDialog(SeqGrabComponent seqGrab,
                                     SGChannel sgchanVideo, WindowPtr gMonitor)
{
        OSErr err;
        Component *panelListPtr = NULL;
        UInt8 numberOfPanels = 0;

        ComponentDescription cd = { SeqGrabPanelType, VideoMediaType, 0, 0, 0 };
        Component c = 0;
        Component *cPtr = NULL;

        numberOfPanels = CountComponents(&cd);
        panelListPtr =
            (Component *) NewPtr(sizeof(Component) * (numberOfPanels + 1));

        cPtr = panelListPtr;
        numberOfPanels = 0;
        CFStringRef compressionCFSTR = CFSTR("Compression");
        do {
                ComponentDescription compInfo;
                c = FindNextComponent(c, &cd);
                if (c) {
                        Handle hName = NewHandle(0);
                        GetComponentInfo(c, &compInfo, hName, NULL, NULL);
                        CFStringRef nameCFSTR =
                            CFStringCreateWithPascalString(kCFAllocatorDefault,
                                                           (unsigned char
                                                            *)(*hName),
                                                           kCFStringEncodingASCII);
                        if (CFStringCompare
                            (nameCFSTR, compressionCFSTR,
                             kCFCompareCaseInsensitive) != kCFCompareEqualTo) {
                                *cPtr++ = c;
                                numberOfPanels++;
                        }
                        DisposeHandle(hName);
                }
        } while (c);

        if ((err =
             SGSettingsDialog(seqGrab, sgchanVideo, numberOfPanels,
                              panelListPtr, seqGrabSettingsPreviewOnly,
                              (SGModalFilterUPP)
                              NewSGModalFilterUPP(SeqGrabberModalFilterProc),
                              (long)gMonitor))) {
                return err;
        }
        return 0;
}
コード例 #5
0
ファイル: _Cmmodule.c プロジェクト: JupiterSmalltalk/openqwaq
static PyObject *Cm_CountComponents(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	long _rv;
	ComponentDescription looking;
#ifndef CountComponents
	PyMac_PRECHECK(CountComponents);
#endif
	if (!PyArg_ParseTuple(_args, "O&",
	                      CmpDesc_Convert, &looking))
		return NULL;
	_rv = CountComponents(&looking);
	_res = Py_BuildValue("l",
	                     _rv);
	return _res;
}
コード例 #6
0
// 1.
// Create the Sequence Grabber (using GWorld as target memory)
void QuicktimeLiveImageStream::createSequenceGrabber()
{
    ComponentDescription sg_component_description;

    sg_component_description.componentType         = SeqGrabComponentType; /* A unique 4-byte code indentifying the command set */
    sg_component_description.componentSubType      = 0L;      /* Particular flavor of this instance */
    sg_component_description.componentManufacturer = 'appl';  /* Vendor indentification */
    sg_component_description.componentFlags        = 0L;      /* 8 each for Component,Type,SubType,Manuf/revision */
    sg_component_description.componentFlagsMask    = 0L;      /* Mask for specifying which flags to consider in search, zero during registration */
    long num_sg_components = CountComponents (&sg_component_description);
    if (num_sg_components)
    {
        Component            aComponent                    = 0;
        ComponentDescription full_sg_component_description = sg_component_description;
        aComponent = FindNextComponent(aComponent, &full_sg_component_description);
        if (aComponent)
        {
            m_gSeqGrabber = OpenComponent(aComponent);
            // If we got a sequence grabber, set it up
            if (m_gSeqGrabber != 0L)
            {
                // Check capability and setting of Sequence Grabber
                GDHandle origDevice;
                CGrafPtr origPort;
                // Create GWorld
                GetGWorld (&origPort, &origDevice);
                SetGWorld (m_gw, NULL); // set current graphics port to offscreen
                // Initialize the sequence grabber
                ComponentResult result = noErr;
                result = SGInitialize (m_gSeqGrabber);
                if (result == noErr)
                {
                    // Set GWorld
                    result = SGSetGWorld(m_gSeqGrabber, (CGrafPtr)m_gw, 0);
                    if (result != noErr)
                    {
                        OSG_FATAL << "Could not set GWorld on SG" << std::endl;
                    }
                }

                // Set GWorld back
                SetGWorld(origPort, origDevice);
            }
        }
    }
}
コード例 #7
0
ファイル: list.c プロジェクト: Gamer125/wiibrowser
int main(void) {
    void *handler;
    ComponentDescription desc;
    Component (*FindNextComponent)(Component prev,ComponentDescription* desc);
    long (*CountComponents)(ComponentDescription* desc);
    OSErr (*InitializeQTML)(long flags);
    OSErr (*EnterMovies)(void);
    OSErr ret;

    Setup_LDT_Keeper();
    handler = LoadLibraryA("/usr/local/lib/codecs/qtmlClient.dll");
    printf("***************************\n");
    InitializeQTML = 0x1000c870; //GetProcAddress(handler, "InitializeQTML");
    EnterMovies = 0x10003ac0; //GetProcAddress(handler, "EnterMovies");
    FindNextComponent = 0x1000d5f0; //GetProcAddress(handler, "FindNextComponent");
    CountComponents = 0x1000d5d0; //GetProcAddress(handler, "CountComponents");
//     = GetProcAddress(handler, "");
    printf("handler: %p, funcs: %p %p %p, %p\n", handler, InitializeQTML, EnterMovies, FindNextComponent,CountComponents);

    ret=InitializeQTML(0);
    printf("InitializeQTML->%d\n",ret);
    ret=EnterMovies();
    printf("EnterMovies->%d\n",ret);

    memset(&desc,0,sizeof(desc));
    desc.componentType= (((unsigned char)'S')<<24)|
			(((unsigned char)'V')<<16)|
			(((unsigned char)'Q')<<8)|
			(((unsigned char)'5'));
    desc.componentSubType=0;
    desc.componentManufacturer=0;
    desc.componentFlags=0;
    desc.componentFlagsMask=0;

    printf("Count = %ld\n",CountComponents(&desc));

    exit(0);
}
コード例 #8
0
ファイル: ve_qtvideo.c プロジェクト: 0p1pp1/mplayer
static int config(struct vf_instance *vf,
        int width, int height, int d_width, int d_height,
	unsigned int flags, unsigned int outfmt){
//    OSErr cres;
    ComponentDescription cdesc;
    mux_v->bih->biWidth=width;
    mux_v->bih->biHeight=height;
    mux_v->bih->biSizeImage=width*height*2;
    mux_v->aspect = (float)d_width/d_height;



    memset(&cdesc,0,sizeof(cdesc));
    cdesc.componentType= (((unsigned char)'i')<<24)|
			(((unsigned char)'m')<<16)|
			(((unsigned char)'c')<<8)|
			(((unsigned char)'o'));

    cdesc.componentSubType=bswap_32(format);
    cdesc.componentManufacturer=0;
    cdesc.componentFlags=0;
    cdesc.componentFlagsMask=0;


    mp_msg(MSGT_MENCODER,MSGL_DBG2,"Count = %ld\n",CountComponents(&cdesc));
    compressor=FindNextComponent(NULL,&cdesc);
    if(!compressor){
	mp_msg(MSGT_MENCODER,MSGL_ERR,"Cannot find requested component\n");
	return 0;
    }
    mp_msg(MSGT_MENCODER,MSGL_DBG2,"Found it! ID = %p\n",compressor);

//	cres= FindCodec (fourcc,anyCodec,&compressor,&decompressor );
//	printf("FindCodec returned:%i compressor: 0x%X decompressor: 0x%X\n",cres&0xFFFF,compressor,decompressor);

    return 1;
}
コード例 #9
0
ファイル: MailContainer.cpp プロジェクト: AmirAbrams/haiku
BMailComponent *BMIMEMultipartMailContainer::GetComponent(int32 index, bool parse_now) {
	if (index >= CountComponents())
		return NULL;
	
	if (BMailComponent *component = (BMailComponent *)_components_in_code.ItemAt(index))
		return component;	//--- Handle easy case

	message_part *part = (message_part *)(_components_in_raw.ItemAt(index));
	if (part == NULL)
		return NULL;

	_io_data->Seek(part->start,SEEK_SET);

	BMailComponent component (_charSetForTextDecoding);
	if (component.SetToRFC822(_io_data,part->end - part->start) < B_OK)
		return NULL;

	BMailComponent *piece = component.WhatIsThis();

	/* Debug code
	_io_data->Seek(part->start,SEEK_SET);
	char *data = new char[part->end - part->start + 1];
	_io_data->Read(data,part->end - part->start);
	data[part->end - part->start] = 0;
	puts((char *)(data));
	printf("Instantiating from %d to %d (%d octets)\n",part->start, part->end, part->end - part->start);
	*/
	_io_data->Seek(part->start,SEEK_SET);
	if (piece->SetToRFC822(_io_data,part->end - part->start, parse_now) < B_OK)
	{
		delete piece;
		return NULL;
	}
	_components_in_code.ReplaceItem(index,piece);

	return piece;
}
コード例 #10
0
// init driver
static int init(sh_video_t *sh){
#ifndef CONFIG_QUICKTIME
    long result = 1;
#endif
    ComponentResult cres;
    ComponentDescription desc;
    Component prev=NULL;
    CodecInfo cinfo;	// for ImageCodecGetCodecInfo()
    ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize()

    codec_initialized = 0;
#ifdef CONFIG_QUICKTIME
    EnterMovies();
#else

#ifdef WIN32_LOADER
    Setup_LDT_Keeper();
#endif

    //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
    qtime_qts = LoadLibraryA("QuickTime.qts");
    if(!qtime_qts){
    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" );
    return 0;
    }

    handler = LoadLibraryA("qtmlClient.dll");
    if(!handler){
    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
    return 0;
    }

    InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
    EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies");
    FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent");
    CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents");
    GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo");
    OpenComponent = (ComponentInstance (*)(Component))GetProcAddress(handler, "OpenComponent");
    ImageCodecInitialize = (ComponentResult (*)(ComponentInstance,ImageSubCodecDecompressCapabilities *))GetProcAddress(handler, "ImageCodecInitialize");
    ImageCodecGetCodecInfo = (ComponentResult (*)(ComponentInstance,CodecInfo *))GetProcAddress(handler, "ImageCodecGetCodecInfo");
    ImageCodecBeginBand = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *,ImageSubCodecDecompressRecord *,long))GetProcAddress(handler, "ImageCodecBeginBand");
    ImageCodecPreDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecPreDecompress");
    ImageCodecBandDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecBandDecompress");
    GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
    QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
    NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear");
    //     = GetProcAddress(handler, "");

    if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n");
	return 0;
    }

    result=InitializeQTML(6+16);
//    result=InitializeQTML(0);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result);
//    result=EnterMovies();
//    printf("EnterMovies->%d\n",result);
#endif /* CONFIG_QUICKTIME */

#if 0
    memset(&desc,0,sizeof(desc));
    while((prev=FindNextComponent(prev,&desc))){
	ComponentDescription desc2;
	unsigned char* c1=&desc2.componentType;
	unsigned char* c2=&desc2.componentSubType;
	memset(&desc2,0,sizeof(desc2));
//	printf("juhee %p (%p)\n",prev,&desc);
	GetComponentInfo(prev,&desc2,NULL,NULL,NULL);
	mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n",
	    c1[3],c1[2],c1[1],c1[0],
	    c2[3],c2[2],c2[1],c2[0],
	    desc2.componentType,desc2.componentSubType,
	    desc2.componentFlags);
    }
#endif


    memset(&desc,0,sizeof(desc));
    desc.componentType= (((unsigned char)'i')<<24)|
			(((unsigned char)'m')<<16)|
			(((unsigned char)'d')<<8)|
			(((unsigned char)'c'));
#if 0
    desc.componentSubType=
		    (((unsigned char)'S'<<24))|
			(((unsigned char)'V')<<16)|
			(((unsigned char)'Q')<<8)|
			(((unsigned char)'3'));
#else
    desc.componentSubType = bswap_32(sh->format);
#endif
    desc.componentManufacturer=0;
    desc.componentFlags=0;
    desc.componentFlagsMask=0;

    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc));
    prev=FindNextComponent(NULL,&desc);
    if(!prev){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n");
	return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev);

    ci=OpenComponent(prev);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci);

    memset(&icap,0,sizeof(icap));
    cres=ImageCodecInitialize(ci,&icap);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x  size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize);

    memset(&cinfo,0,sizeof(cinfo));
    cres=ImageCodecGetCodecInfo(ci,&cinfo);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X  decomp: 0x%X format: 0x%X\n",
	cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0],
	((unsigned char*)&cinfo.typeName)+1);

    //make a yuy2 gworld
    OutBufferRect.top=0;
    OutBufferRect.left=0;
    OutBufferRect.right=sh->disp_w;
    OutBufferRect.bottom=sh->disp_h;

    //Fill the imagedescription for our SVQ3 frame
    //we can probably get this from Demuxer
#if 0
    framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200);
    printf("framedescHandle=%p  *p=%p\n",framedescHandle,*framedescHandle);
{ FILE* f=fopen("/root/.wine/fake_windows/IDesc","r");
  if(!f) printf("filenot found: IDesc\n");
  fread(*framedescHandle,sizeof(ImageDescription)+200,1,f);
  fclose(f);
}
#else
    if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
    framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
    memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
    dump_ImageDescription(*framedescHandle);
#endif
//Find codecscomponent for video decompression
//    result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor );
//    printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor);

    sh->context = (void *)kYUVSPixelFormat;
#if 1
    {
	int imgfmt = sh->codec->outfmt[sh->outfmtidx];
	int qt_imgfmt;
    switch(imgfmt)
    {
	case IMGFMT_YUY2:
	    qt_imgfmt = kYUVSPixelFormat;
	    break;
	case IMGFMT_YVU9:
	    qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
	    break;
	case IMGFMT_YV12:
	    qt_imgfmt = 0x79343230;
	    break;
	case IMGFMT_UYVY:
	    qt_imgfmt = kUYVY422PixelFormat;
	    break;
	case IMGFMT_YVYU:
	    qt_imgfmt = kYVYU422PixelFormat;
	    imgfmt = IMGFMT_YUY2;
	    break;
	case IMGFMT_RGB16:
	    qt_imgfmt = k16LE555PixelFormat;
	    break;
	case IMGFMT_BGR24:
	    qt_imgfmt = k24BGRPixelFormat;
	    break;
	case IMGFMT_BGR32:
	    qt_imgfmt = k32BGRAPixelFormat;
	    break;
	case IMGFMT_RGB32:
	    qt_imgfmt = k32RGBAPixelFormat;
	    break;
	default:
	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
	    return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt);
    sh->context = (void *)qt_imgfmt;
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
    }
#else
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
#endif

    return 1;
}
コード例 #11
0
ファイル: Junction.c プロジェクト: Rollmops/via
/*
** correct topological labelling. Some surface points must be relabelled
** as junctions.
*/
VImage
VJunction(VImage src,VImage topo)
{
  VImage tmp1,tmp2;
  int nbands,nrows,ncols;
  int b,r,c,bb,rr,cc,bbb,rrr,ccc;
  VBit *bit_pp,*bin_pp,u;
  int i,npix;

  nbands = VImageNBands(src);
  nrows = VImageNRows(src);
  ncols = VImageNColumns(src);

  ldest = VCreateImage(5,5,5,VUByteRepn);
  tmp1 = VCreateImage(5,5,5,VBitRepn);
  tmp2 = VCreateImage(5,5,5,VBitRepn);
  npix = 5 * 5 * 5;

  QueueSize = npix;
  queue.A = (Voxel *) VMalloc(sizeof(Voxel) * QueueSize);

  for (b=2; b<nbands-2; b++) {
    for (r=2; r<nrows-2; r++) {
      for (c=2; c<ncols-2; c++) {

	if (VPixel(topo,b,r,c,VUByte) != 6) continue;

	bit_pp = (VBit *) VPixelPtr(tmp1,0,0,0);
	for (i=0; i<npix; i++) *bit_pp++ = 0;

	bit_pp = VPixelPtr(tmp2,0,0,0);
	for (i=0; i<npix; i++) *bit_pp++ = 0;

	for (bb=b-1; bb<=b+1; bb++) {
	  for (rr=r-1; rr<=r+1; rr++) {
	    for (cc=c-1; cc<=c+1; cc++) {

	      if (ABS(bb-b) + ABS(rr-r) + ABS(cc-c) > 2) continue;
	      u = VPixel(src,bb,rr,cc,VBit);
	      VPixel(tmp1,bb-b+1,rr-r+1,cc-c+1,VBit) = ~ u;
	    }
	  }
	}
	VPixel(tmp1,2,2,2,VBit) = 0;

	for (bb=b-1; bb<=b+1; bb++) {
	  for (rr=r-1; rr<=r+1; rr++) {
	    for (cc=c-1; cc<=c+1; cc++) {
	      if (VPixel(topo,bb,rr,cc,VUByte) != 6) continue;

	      bit_pp = VPixelPtr(tmp2,0,0,0);
	      for (i=0; i<npix; i++) *bit_pp++ = 0;

	      for (bbb=bb-1; bbb<=bb+1; bbb++) {
		for (rrr=rr-1; rrr<=rr+1; rrr++) {
		  for (ccc=cc-1; ccc<=cc+1; ccc++) {

		    if (ABS(bbb-bb) + ABS(rrr-rr) + ABS(ccc-cc) > 2) continue;
		    u = VPixel(src,bbb,rrr,ccc,VBit);
		    VPixel(tmp2,bbb-bb+1,rrr-rr+1,ccc-cc+1,VBit) = ~ u;
		  }
		}
	      }
	      VPixel(tmp2,2,2,2,VBit) = 0;

	      bit_pp = (VBit *) VPixelPtr(tmp1,0,0,0);
	      bin_pp = (VBit *) VPixelPtr(tmp2,0,0,0);
	      for (i=0; i<npix; i++) {
		*bin_pp++ = *bit_pp | *bit_pp;
		bin_pp++;
		bit_pp++;
	      }

	      if (CountComponents(tmp2) > 2) {
		VPixel(topo,b,r,c,VUByte) = 7;
		goto skip;
	      }
	    }
	  }
	}
      skip: ;
      }
    }
  }
  return topo;
}