void MediaRoutingView::_changeBackground(
	entry_ref *ref)
{
	D_METHOD(("MediaRoutingView::_changeBackground()\n"));

	status_t error;
	BBitmap *background = 0; 
	BFile file(ref, B_READ_ONLY); 
	error = file.InitCheck();
	if (!error)
	{
		BTranslatorRoster *roster = BTranslatorRoster::Default(); 
		BBitmapStream stream; 
		error = roster->Translate(&file, NULL, NULL, &stream, B_TRANSLATOR_BITMAP);
		if (!error)
		{
			stream.DetachBitmap(&background); 
			setBackgroundBitmap(background);
			Invalidate();

			// [e.moon 1dec99] persistence, yay
			m_backgroundBitmapEntry.SetTo(ref);
		}
	}
	delete background;
}
Beispiel #2
0
// ---------------------------------------------------------------
// GetBitmap
//
// Returns a BBitmap object from the BPositionIO *stream. The
// user must delete the returned object. This GetBitmap function
// is used by the other GetBitmap functions to do all of the
// "real" work.
//
// Preconditions:
//
// Parameters: stream, the stream with bitmap data in it
//             roster, BTranslatorRoster used to do the translation
//
// Postconditions:
//
// Returns: NULL, if the stream couldn't be translated to a BBitmap
//          BBitmap * for the bitmap data from pio if successful
// ---------------------------------------------------------------
BBitmap *
BTranslationUtils::GetBitmap(BPositionIO *stream, BTranslatorRoster *roster)
{
	if (stream == NULL)
		return NULL;
	
	// Use default Translator if none is specified 
	if (roster == NULL) {
		roster = BTranslatorRoster::Default();
		if (roster == NULL)
			return NULL;
	}

	// Translate the file from whatever format it is in the file
	// to the type format so that it can be stored in a BBitmap
	BBitmapStream bitmapStream;
	if (roster->Translate(stream, NULL, NULL, &bitmapStream,
		B_TRANSLATOR_BITMAP) < B_OK)
		return NULL;
	
	// Detach the BBitmap from the BBitmapStream so the user
	// of this function can do what they please with it.
	BBitmap *pBitmap = NULL;
	if (bitmapStream.DetachBitmap(&pBitmap) == B_NO_ERROR)
		return pBitmap;
	else
		return NULL;
}
Beispiel #3
0
status_t
SlideShowSaver::SetImage(const entry_ref *pref)
{
	entry_ref ref;
	if (!pref)
		ref = fCurrentRef;
	else
		ref = *pref;

	BTranslatorRoster *proster = BTranslatorRoster::Default();
	if (!proster)
		return B_ERROR;

	if (ent_is_dir(pref) != B_OK)
		// if ref is erroneous or a directory, return error
		return B_ERROR;

	BFile file(&ref, B_READ_ONLY);
	translator_info info;
	memset(&info, 0, sizeof(translator_info));
	BMessage ioExtension;
	//if (ref != fCurrentRef)
		// if new image, reset to first document
	//	fDocumentIndex = 1;
	if (ioExtension.AddInt32("/documentIndex", 1 /*fDocumentIndex*/) != B_OK)
		return B_ERROR;
	if (proster->Identify(&file, &ioExtension, &info, 0, NULL,
		B_TRANSLATOR_BITMAP) != B_OK)
		return B_ERROR;

	// Translate image data and create a new ShowImage window
	BBitmapStream outstream;
	if (proster->Translate(&file, &info, &ioExtension, &outstream,
		B_TRANSLATOR_BITMAP) != B_OK)
		return B_ERROR;
	BBitmap *newBitmap = NULL;
	if (outstream.DetachBitmap(&newBitmap) != B_OK)
		return B_ERROR;

	// Now that I've successfully loaded the new bitmap,
	// I can be sure it is safe to delete the old one,
	// and clear everything
	delete fBitmap;
	fBitmap = newBitmap;
	newBitmap = NULL;
	fCurrentRef = ref;

	// Get path to use in caption
	fCaption = "<< Unable to read the path >>";
	BEntry entry(&fCurrentRef);
	if (entry.InitCheck() == B_OK) {
		BPath path(&entry);
		if (path.InitCheck() == B_OK) {
			fCaption = path.Path();
		}
	}

	return B_OK;
}
BBitmap * RBitmapLoader::TranslateBitmap(const char *name)
{
	 BPath path(&mAppDir, name);
	 BFile file(path.Path(), B_READ_ONLY); 
	 BTranslatorRoster *roster; 
	 BBitmapStream stream; 
	 BBitmap *result = NULL; 
	 roster = BTranslatorRoster::Default();
	 if (roster->Translate(&file, NULL, NULL, &stream,  B_TRANSLATOR_BITMAP) < B_OK) 
		 result = NULL; 
	 else stream.DetachBitmap(&result); 
	 return result; 
}
Beispiel #5
0
status_t
PictureView::_LoadPicture(const entry_ref* ref)
{
	BFile file;
	status_t status = file.SetTo(ref, B_READ_ONLY);
	if (status != B_OK)
		return status;

	off_t fileSize;
	status = file.GetSize(&fileSize);
	if (status != B_OK)
		return status;

	// Check that we've at least some data to translate...
	if (fileSize < 1)
		return B_OK;

	translator_info info;
	memset(&info, 0, sizeof(translator_info));
	BMessage ioExtension;

	BTranslatorRoster* roster = BTranslatorRoster::Default();
	if (roster == NULL)
		return B_ERROR;

	status = roster->Identify(&file, &ioExtension, &info, 0, NULL,
		B_TRANSLATOR_BITMAP);

	BBitmapStream stream;

	if (status == B_OK) {
		status = roster->Translate(&file, &info, &ioExtension, &stream,
			B_TRANSLATOR_BITMAP);
	}
	if (status != B_OK)
		return status;

	BBitmap* picture = NULL;
	if (stream.DetachBitmap(&picture) != B_OK
		|| picture == NULL)
		return B_ERROR;

	// Remember image format so we could store using the same
	fPictureMIMEType = info.MIME;
	fPictureType = info.type;

	_SetPicture(picture);
	return B_OK;
}
/*=============================================================================================*\
|	FetchBitmap																					|
+-----------------------------------------------------------------------------------------------+
|	Effet: Converie une image en un BBitmap. La couleur de transparence est celle du pixel dans	|
|			le coin superieur gauche.															|
|	Entree:																						|
|		char *pzFileName: Le path du fichier image a convertir.									|
|		bool bTran: True si on utilise la transparence, false sinon.							|
|	Sortie:																						|
|		BBitmap *: Le pointeur le bitmap de l'image. NULL si la conversion a echouer.			|
\*=============================================================================================*/
BBitmap*
BitmapCatalog::FetchBitmap(char* pzFileName, bool bTrans) 
{ 


	BFile file(pzFileName, B_READ_ONLY); 
	BTranslatorRoster *roster = BTranslatorRoster::Default(); 
	BBitmapStream stream; 
	BBitmap *result = NULL; 
	if (roster->Translate(&file, NULL, NULL, &stream, B_TRANSLATOR_BITMAP) < B_OK) 
		return NULL; 
	stream.DetachBitmap(&result); 


//  OliverESP: 7 x 1 so -> #include <TranslationUtils.h> //OliverESP:
//			   less code and works
	//BBitmap *result = BTranslationUtils::GetBitmapFile(pzFileName);
	
	if (result == NULL)
		return NULL;

	if(!bTrans)
		return result;
	
	int32 iLenght = result->BitsLength() / 4;
	int32 i;
	int32 * cBit = (int32*)result->Bits();
	int32 backColor = cBit[result->Bounds().IntegerWidth() - 1];
	int32 iTrans = 0;
      
	//Determine le mode de definition de couleur
	switch(result->ColorSpace())
	{
	case B_RGB32:		iTrans = B_TRANSPARENT_MAGIC_RGBA32; break;
	case B_RGB32_BIG:	iTrans = B_TRANSPARENT_MAGIC_RGBA32_BIG; break;
	default:			break; //TODO: Major screwup here!
	}

	if (iTrans)
	{
		for(i = 0; i < iLenght; i++)
		{
			if(cBit[i] == backColor)
				cBit[i] = iTrans;
		}
	}

	return result; 
}
Beispiel #7
0
ImageView::ImageView(BPositionIO *image)
	:
	BView(BRect(0, 0, 1, 1), "image_view", B_FOLLOW_NONE, B_WILL_DRAW),
	fSuccess(true)
{
	if (!image) {
		fSuccess = false;
		return;
	}
	// Initialize and translate the image
	BTranslatorRoster *roster = BTranslatorRoster::Default();
	BBitmapStream stream;
	if (roster->Translate(image, NULL, NULL, &stream, B_TRANSLATOR_BITMAP)
			< B_OK) {
		fSuccess = false;
		return;
	}
	stream.DetachBitmap(&fImage);
}
/*=============================================================================================*\
|	FetchBitmap																					|
+-----------------------------------------------------------------------------------------------+
|	Effet: Converie une image en un BBitmap. La couleur de transparence est celle du pixel dans	|
|			le coin superieur gauche.															|
|	Entree:																						|
|		char *pzFileName: Le path du fichier image a convertir.									|
|		bool bTran: True si on utilise la transparence, false sinon.							|
|	Sortie:																						|
|		BBitmap *: Le pointeur le bitmap de l'image. NULL si la conversion a echouer.			|
\*=============================================================================================*/
BBitmap * BeNetBitmapCatalog::FetchBitmap(char *pzFileName, bool bTrans) 
{ 
      BFile file(pzFileName, B_READ_ONLY); 
      BTranslatorRoster *roster = BTranslatorRoster::Default(); 
      BBitmapStream stream; 
      BBitmap *result = NULL; 
      if (roster->Translate(&file, NULL, NULL, &stream, 
            B_TRANSLATOR_BITMAP) < B_OK) 
         return NULL; 
      stream.DetachBitmap(&result); 
            
      
      if(!bTrans) return result;
      int32 iLenght = result->BitsLength() / 4;
      int32 i;
      int32 * cBit = (int32)result->Bits();
      int32 backColor = cBit[result->Bounds().IntegerWidth() - 1];
      int32 iTrans = 0;
      
      //Determine le mode de definition de couleur
      switch(result->ColorSpace())
      {
      		case B_RGB32:{
      				iTrans = B_TRANSPARENT_MAGIC_RGBA32;
      			}break;
      		case B_RGB32_BIG:{
      				iTrans = B_TRANSPARENT_MAGIC_RGBA32_BIG;
      			}break;
       }
      
      if(iTrans)
      {
     	for(i = 0; i < iLenght; i++)
      	{
      		if(cBit[i] == backColor)
      		{
     			cBit[i] = B_TRANSPARENT_MAGIC_RGBA32_BIG;
      		}
      	}
      }
      
      return result; 
}//Fin de FetchBitmap.
Beispiel #9
0
void PictureViewer::HandleMimeData(BMessage *e) {
    int32 numBytes;
    type_code type;
    const void *data;
    const char *m_type;
    if (e->GetInfo( B_MIME_TYPE, 0, (char**)&m_type, &type, &numBytes) != B_OK) return;

    e->FindData(m_type,B_MIME_TYPE,&data,&numBytes);
    BMemoryIO memStream(data, numBytes);
    BBitmapStream imageStream;
    if (strcmp(m_type,"image/x-be-bitmap")==0) {
     uint8 buffer[1024];
     int32 size;
     while ((size=memStream.Read(buffer,1024))>0) 
       imageStream.Write(buffer,size);
    } 
    else if ( BTranslatorRoster::Default()->Translate(&memStream,NULL,NULL, &imageStream, B_TRANSLATOR_BITMAP, 0, m_type) != B_OK) return;

    BBitmap *bmp;
    imageStream.DetachBitmap(&bmp);
    ((WindowPeek*)Window())->LoadImage(bmp);
    return;  
}
void
ImageView::SetImage(BMessage *pmsg)
{
	// Replace current image with the image
	// specified in the given BMessage

	entry_ref ref;
	if (!pmsg)
		ref = fcurrentRef;
	else if (pmsg->FindRef("refs", &ref) != B_OK)
		// If refs not found, just ignore the message
		return;

	StatusCheck chk;

	try {
		BFile file(&ref, B_READ_ONLY);
		chk = file.InitCheck();

		BTranslatorRoster roster, *proster;
		proster = SelectTranslatorRoster(roster);
		if (!proster)
			// throw exception
			chk = B_ERROR;
		// determine what type the image is
		translator_info tinfo;
		BMessage ioExtension;
		if (ref != fcurrentRef)
			// if new image, reset to first document
			fdocumentIndex = 1;
		chk = ioExtension.AddInt32("/documentIndex", fdocumentIndex);
		chk = proster->Identify(&file, &ioExtension, &tinfo, 0, NULL,
			B_TRANSLATOR_BITMAP);

		// perform the actual translation
		BBitmapStream outstream;
		chk = proster->Translate(&file, &tinfo, &ioExtension, &outstream,
			B_TRANSLATOR_BITMAP);
		BBitmap *pbitmap = NULL;
		chk = outstream.DetachBitmap(&pbitmap);
		delete fpbitmap;
		fpbitmap = pbitmap;
		pbitmap = NULL;
		fcurrentRef = ref;
			// need to keep the ref around if user wants to switch pages
		int32 documentCount = 0;
		if (ioExtension.FindInt32("/documentCount", &documentCount) == B_OK &&
			documentCount > 0)
			fdocumentCount = documentCount;
		else
			fdocumentCount = 1;

		// Set the name of the Window to reflect the file name
		BWindow *pwin = Window();
		BEntry entry(&ref);
		BPath path;
		if (entry.InitCheck() == B_OK) {
			if (path.SetTo(&entry) == B_OK)
				pwin->SetTitle(path.Leaf());
			else
				pwin->SetTitle(IMAGEWINDOW_TITLE);
		} else
			pwin->SetTitle(IMAGEWINDOW_TITLE);
		UpdateInfoWindow(path, ioExtension, tinfo, proster);

		// Resize parent window and set size limits to
		// reflect the size of the new bitmap
		float width, height;
		BMenuBar *pbar = pwin->KeyMenuBar();
		width = fpbitmap->Bounds().Width() + B_V_SCROLL_BAR_WIDTH + (BORDER_WIDTH * 2);
		height = fpbitmap->Bounds().Height() +
			pbar->Bounds().Height() + B_H_SCROLL_BAR_HEIGHT + (BORDER_HEIGHT * 2) + 1;
		BScreen *pscreen = new BScreen(pwin);
		BRect rctscreen = pscreen->Frame();
		if (width > rctscreen.Width())
			width = rctscreen.Width();
		if (height > rctscreen.Height())
			height = rctscreen.Height();
		pwin->SetSizeLimits(B_V_SCROLL_BAR_WIDTH * 4, width,
			pbar->Bounds().Height() + (B_H_SCROLL_BAR_HEIGHT * 4) + 1, height);
		pwin->SetZoomLimits(width, height);
		AdjustScrollBars();

		//pwin->Zoom();
			// Perform all of the hard work of resizing the
			// window while taking into account the size of
			// the screen, the tab and borders of the window
			//
			// HACK: Need to fix case where window un-zooms
			// when the window is already the correct size
			// for the current image

		// repaint view
		Invalidate();

	} catch (StatusNotOKException) {
		BAlert *palert = new BAlert(NULL,
			B_TRANSLATE("Sorry, unable to load the image."),
			B_TRANSLATE("OK"));
		palert->Go();
	}
}
BBitmap *RBitmapLoader::LoadBitmap(const char *name)
{
	// Init App 
	if (!initied) init();
	// try to load image from ressource
	BBitmap *mImage32  = 0;
	app_info info;
	be_app->GetAppInfo(&info);
	BFile resFile(&info.ref, B_READ_WRITE);
	if (resFile.InitCheck() == B_NO_ERROR)
	{
		BResources res(&resFile);
		int32 idFound;
		size_t size;
		if (res.GetResourceInfo('IMAG', name, &idFound, &size))
		{
			// ressource exist, load it into a buffer
			char *image_data = new char[size];
             ASSERT(image_data);
			if (res.ReadResource('IMAG', idFound, image_data, 0, size) == B_NO_ERROR)
			{
				// map a BMemoryIO to point onto these data
				BMemoryIO mem(image_data, size);
				
				// read with translation kit from the data
				BTranslatorRoster *roster = BTranslatorRoster::Default(); 
				BBitmapStream stream; 
				if (roster->Translate(&mem, NULL, NULL, &stream,  B_TRANSLATOR_BITMAP) >= B_OK)
					stream.DetachBitmap(&mImage32); 
			}
			// delete buffer
			delete image_data;
		}
	}

	if (!mImage32)
	{
		printf("Load into resource %s\n",name);
		// if not in ressource, load from file and copy into ressources
		mImage32 = TranslateBitmap(name);
		if (!mImage32) 
		{
			return NULL;
		}
		// try to put into ressource
		BPath path(&mAppDir, name);
		BFile input(path.Path(), B_READ_ONLY);
		if (resFile.InitCheck() == B_NO_ERROR && input.InitCheck() == B_NO_ERROR)
		{
			BResources res(&resFile);
			input.Seek(0, SEEK_END);
			off_t insize = input.Position();
			input.Seek(0, SEEK_SET);
			char *data = new char[insize];
			if (data)
			{
				input.Read(data, insize);
				if (res.AddResource('IMAG',  g_current_id , data, insize, name)==B_OK)
				{
					g_current_id ++;
				}
				delete data;
			}
		}
	}
	return mImage32;
} 
Beispiel #12
0
void
BitmapView::MessageReceived(BMessage *msg)
{
	if (msg->WasDropped() && AcceptsDrops()) {
		// We'll handle two types of drops: those from Tracker and those from ShowImage
		if (msg->what == B_SIMPLE_DATA) {
			int32 actions;
			if (msg->FindInt32("be:actions", &actions) == B_OK) {
				// ShowImage drop. This is a negotiated drag&drop, so send a reply
				BMessage reply(B_COPY_TARGET), response;
				reply.AddString("be:types", "image/jpeg");
				reply.AddString("be:types", "image/png");
				
				msg->SendReply(&reply, &response);
				
				// now, we've gotten the response
				if (response.what == B_MIME_DATA) {
					// Obtain and translate the received data
					uint8 *imagedata;
					ssize_t datasize;
										
					// Try JPEG first
					if (response.FindData("image/jpeg", B_MIME_DATA, 
						(const void **)&imagedata, &datasize) != B_OK) {
						// Try PNG next and piddle out if unsuccessful
						if (response.FindData("image/png", B_PNG_FORMAT, 
							(const void **)&imagedata, &datasize) != B_OK)
							return;
					}
					
					// Set up to decode into memory
					BMemoryIO memio(imagedata, datasize);
					BTranslatorRoster *roster = BTranslatorRoster::Default();
					BBitmapStream bstream;
					
					if (roster->Translate(&memio, NULL, NULL, &bstream, B_TRANSLATOR_BITMAP) == B_OK)
					{
						BBitmap *bmp;
						if (bstream.DetachBitmap(&bmp) != B_OK)
							return;
						SetBitmap(bmp);
						
						if (fConstrainDrops)
							ConstrainBitmap();
						Invoke();
					}
				}
				return;
			}
			
			entry_ref ref;
			if (msg->FindRef("refs", &ref) == B_OK) {
				// Tracker drop
				BBitmap *bmp = BTranslationUtils::GetBitmap(&ref);
				if (bmp) {
					SetBitmap(bmp);
					
					if (fConstrainDrops)
						ConstrainBitmap();
					Invoke();
				}
			}
		}
		return;
	}
	
	switch (msg->what)
	{
		case M_REMOVE_IMAGE: {
			BAlert *alert = new BAlert("ResEdit", "This cannot be undone. "
				"Remove the image?", "Remove", "Cancel");
			alert->SetShortcut(1, B_ESCAPE);
			int32 value = alert->Go();
			if (value == 0) {
				SetBitmap(NULL);
				
				if (Target()) {
					BMessenger msgr(Target());
					
					msgr.SendMessage(new BMessage(M_BITMAP_REMOVED));
					return;
				}
			}
		}
		case M_PASTE_IMAGE:
		{
			PasteBitmap();
			Invoke();
		}
	}
	BView::MessageReceived(msg);
}
Beispiel #13
0
int
main(int argc, char **argv)
{
	BApplication app("application/x-vnd.Antares-RAWTranslator");

#if TEST_MODE
	if (argc > 1) {
		for (int i = 1; i < argc; i++) {
			BFile file;
			status_t status = file.SetTo(argv[i], B_READ_ONLY);
			if (status != B_OK) {
				fprintf(stderr, "Cannot read file %s: %s\n", argv[i],
					strerror(status));
				continue;
			}

			DCRaw raw(file);

			try {
				status = raw.Identify();
			} catch (status_t error) {
				status = error;
			}

			if (status < B_OK) {
				fprintf(stderr, "Could not identify file %s: %s\n",
					argv[i], strerror(status));
				continue;
			}

			image_meta_info meta;
			raw.GetMetaInfo(meta);

			printf("manufacturer: %s\n", meta.manufacturer);
			printf("model: %s\n", meta.model);
			printf("software: %s\n", meta.software);
			printf("flash used: %g\n", meta.flash_used);
			printf("ISO speed: %g\n", meta.iso_speed);
			printf("shutter: ");
			if (meta.shutter >= 1)
				printf("%g sec\n", meta.shutter);
			else
				printf("1/%g sec\n", 1 / meta.shutter);
			printf("aperture: %g\n", meta.aperture);
			printf("focal length: %g mm\n", meta.focal_length);
			printf("pixel aspect: %g\n", meta.pixel_aspect);
			printf("flip: %d\n", meta.flip);
			printf("shot order: %ld\n", meta.shot_order);
			printf("DNG version: %ld\n", meta.dng_version);
			printf("Camera White Balance:");
			for (int32 i = 0; i < 4; i++) {
				printf(" %g", meta.camera_multipliers[i]);
			}
			putchar('\n');

			for (int32 i = 0; i < (int32)raw.CountImages(); i++) {
				image_data_info data;
				raw.ImageAt(i, data);

				printf("  [%ld] %s %lu x %lu (%ld bits per sample, compression %ld)\n",
					i, data.is_raw ? "RAW " : "JPEG",
					data.width, data.height, data.bits_per_sample, data.compression);

#	if SHOW_MODE
				if (!data.is_raw) {
					// write data to file
					uint8* buffer;
					size_t bufferSize;
					try {
						status = raw.ReadImageAt(i, buffer, bufferSize);
					} catch (status_t error) {
						status = error;
					}
					if (status == B_OK) {
						BString name = "/tmp/output";
						name << i << ".jpg";
						BFile output(name.String(),
							B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
						output.Write(buffer, bufferSize);
					}
				} else {
					RAWTranslator translator;
					BBitmapStream output;
					BBitmap* bitmap;

					status_t status = translator.DerivedTranslate(&file, NULL,
						NULL, B_TRANSLATOR_BITMAP, &output, 0);
					if (status == B_OK)
						status = output.DetachBitmap(&bitmap);
					if (status == B_OK) {
						BWindow* window = new BWindow(BRect(0, 0, 1, 1),
							"RAW", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS
							| B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS);
						BView* view = new BView(window->Bounds(), NULL,
							B_WILL_DRAW, B_FOLLOW_NONE);
						window->AddChild(view);
						window->SetLayout(new BGroupLayout(B_HORIZONTAL));
						window->Show();
						snooze(300000);
						window->Lock();
						view->DrawBitmap(bitmap, window->Bounds());
						view->Sync();
						window->Unlock();
						delete bitmap;

						wait_for_thread(window->Thread(), &status);
					}
				}
#	endif
			}
		}
		return 0;
	}
#endif

	status_t status = LaunchTranslatorWindow(new RAWTranslator, "RAW Settings");
	if (status != B_OK)
		return 1;

	app.Run();
	return 0;
}
Beispiel #14
0
void PictureViewer::HandleCopyTarget(BMessage *e) {
  entry_ref targetRef;
   
  BBitmap *toSend;
  if (clipping == true) toSend = GetClipping();
                   else toSend = thePic;
  


  // memory or file transfer ?
  if (e->FindRef("directory",&targetRef) == B_OK)  {

      BDirectory *targetDir = new BDirectory( &targetRef );
      if (targetDir->InitCheck() == B_OK) {
         BFile *targetFile = new BFile(targetDir,e->FindString("name"),B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
         if (targetFile->InitCheck() == B_OK) {

          BBitmap *dragImage = NULL;
          BBitmapStream *strm;
          strm = new BBitmapStream(toSend);

          translator_id trans_id;
          uint32 type;

          GetTranslatorInfo(e->FindString("be:filetypes"),&trans_id,&type);
          BTranslatorRoster::Default()->Translate(trans_id,strm,NULL,targetFile,type);
          BNodeInfo *ni = new BNodeInfo(targetFile);
          ni->SetType(e->FindString("be:filetypes"));
          if (dragImage == NULL) strm->DetachBitmap(&toSend);
           else {
            strm->DetachBitmap(&dragImage);
            delete dragImage;
           }
          delete ni;
          delete strm;
         } 
        delete targetFile;
       }   
     delete targetDir;
     return;
   } 
   
  else {
     BMallocIO *data = new BMallocIO;
     BBitmapStream *imageSrc;
     imageSrc = new BBitmapStream(toSend);

     BMessage *package = new BMessage(B_MIME_DATA);
     translator_id trans_id;
     uint32 type;

     GetTranslatorInfo(e->FindString("be:types"),&trans_id,&type);
     if (BTranslatorRoster::Default()->Translate( trans_id, imageSrc, NULL, data, type ) != B_OK) return;
     package->AddData( e->FindString("be:types"),  B_MIME_DATA, data->Buffer(), data->BufferLength());
     e->SendReply(package);        

     imageSrc->DetachBitmap(&toSend);

     delete data;
     delete imageSrc;
     delete package;
  } 

 if (clipping) delete toSend;

}