RE: [flexcoders] How to download a BLOB from database....using Java

2008-04-13 Thread Jim Hayes
Ok, gotcha!
You need to use Loader.loadBytes(b:byteArray)

var loader:Loader = new Loader();

loader.loadBytes(yourByteArray);

Now, the bitmap *will* be available in the loaders “content” property, but do 
not assume that just because you gave it a preloaded bytearray that it will be 
*immediately* available. Or you will be sad and confused, as was I :)

No, the bitmap will only be available once the loader.contentLoaderInfo 
complete event fires.

So, add an event listener for the complete event :

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaderCompleteHandler);

Then get the bitmap from the loader at that point in time :

private function loaderCompleteHandler(event:Event)

{

var loader:Loader = event.target as Loader;
var bmp:Bitmap = Bitmap(loader.content);
// do something with bmp here, such as displaying it.
}

I'm not sure if the image component now will take a byteArray directly, there 
was some talk of it a few months back so it may have got added to the flex 3 
code.


-Original Message-
From: flexcoders@yahoogroups.com on behalf of Jon Santos
Sent: Sat 12/04/2008 13:01
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] How to download a BLOB from databaseusing Java
 
Hi Jim.i know how to get the image in my POJO.

The process i´m following: 

I get the image form database throw my servlet. In this class i get the 
ImageObject (POJO), it means the image and other data.
In my FLEX application i have one object ImageObject (Action Script)like 
Remote Object for the java objectthen i able to get the image and the other 
data in my FLEX application

The unique problem i´m finding : I don´t know how to display in my FLEX 
application (it means your B question).i don´t know which component i must 
use to display my image (array of bytes).

Thanks in advanceand i hope u already understad my problem.

- Original Message 
From: Jim Hayes [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Friday, April 11, 2008 11:53:38 PM
Subject: RE: [flexcoders] How to download a BLOB from databaseusing Java


Is your question
a) how to get the byteArray into flex?
b) how to display it once it is in flex?
c) both a and b ?

I can help you with b !

-Original Message-
From: [EMAIL PROTECTED] ups.com on behalf of txakin
Sent: Fri 11/04/2008 14:29
To: [EMAIL PROTECTED] ups.com
Subject: [flexcoders] How to download a BLOB from database using Java

Hi all

I would like to know...how to download a BLOB (image, file...binary 
data) from my Oralce database to my Flex application.

I think i already have my servlet createdthe souce can be more 
or less like the next one:

Session session = HibernateSessionFac tory.getSession( );

//Here i get my POJO (my movieImage object)
MovieImage myMovieImage = (MovieImage) session.load( MovieImage. class, 
movieId);

//I got the binary data (in this case one image), into array of bytes
byte[] myCover = myMovieImage. getCover( );
ServletOutputStream servletOutputStream = res.getOutputStream ();
res.setContentType( application/ image);
res.setContentLengt h(myCover. length);
servletOutputStream .write(myCover, 0, myCover.length) ;
servletOutputStream .flush();
servletOutputStream .close();

But my problem is how to show that image in my component... .

Can someone help me (with some source or with some steps or some 
example) to get the solution?

Thansk in advance.

 _ _ _ _ _ _
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please then delete the e-mail and do not disclose its contents to any 
person.
This email has been scanned for Primal Pictures by the MessageLabs Email 
Security System.
 _ _ _ _ _ _
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


__
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please

Re: [flexcoders] How to download a BLOB from database....using Java

2008-04-12 Thread Jon Santos
Hi Jim.i know how to get the image in my POJO.

The process i´m following: 

I get the image form database throw my servlet. In this class i get the 
ImageObject (POJO), it means the image and other data.
In my FLEX application i have one object ImageObject (Action Script)like 
Remote Object for the java objectthen i able to get the image and the other 
data in my FLEX application

The unique problem i´m finding : I don´t know how to display in my FLEX 
application (it means your B question).i don´t know which component i must 
use to display my image (array of bytes).

Thanks in advanceand i hope u already understad my problem.

- Original Message 
From: Jim Hayes [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Friday, April 11, 2008 11:53:38 PM
Subject: RE: [flexcoders] How to download a BLOB from databaseusing Java


Is your question
a) how to get the byteArray into flex?
b) how to display it once it is in flex?
c) both a and b ?

I can help you with b !

-Original Message-
From: [EMAIL PROTECTED] ups.com on behalf of txakin
Sent: Fri 11/04/2008 14:29
To: [EMAIL PROTECTED] ups.com
Subject: [flexcoders] How to download a BLOB from database using Java

Hi all

I would like to know...how to download a BLOB (image, file...binary 
data) from my Oralce database to my Flex application.

I think i already have my servlet createdthe souce can be more 
or less like the next one:

Session session = HibernateSessionFac tory.getSession( );

//Here i get my POJO (my movieImage object)
MovieImage myMovieImage = (MovieImage) session.load( MovieImage. class, 
movieId);

//I got the binary data (in this case one image), into array of bytes
byte[] myCover = myMovieImage. getCover( );
ServletOutputStream servletOutputStream = res.getOutputStream ();
res.setContentType( application/ image);
res.setContentLengt h(myCover. length);
servletOutputStream .write(myCover, 0, myCover.length) ;
servletOutputStream .flush();
servletOutputStream .close();

But my problem is how to show that image in my component... .

Can someone help me (with some source or with some steps or some 
example) to get the solution?

Thansk in advance.

 _ _ _ _ _ _
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please then delete the e-mail and do not disclose its contents to any 
person.
This email has been scanned for Primal Pictures by the MessageLabs Email 
Security System.
 _ _ _ _ _ _
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: [flexcoders] How to download a BLOB from database....using Java

2008-04-12 Thread Muzak
You can use the Loader class.
If your image is Base64 encoded, decode it first, if not, skip that part and 
use the Loader only.
Here's something I'm using to display BLOB images stored in an SQLite DB (AIR).

I've skipped a few things, but should get you going.
The important part is that you use a Loader instance to transform the ByteArray 
into a Bitmap instance.

 mx:Script
  ![CDATA[

   import mx.utils.Base64Decoder;
   import mx.utils.Base64Encoder;
   import mx.graphics.codec.JPEGEncoder;

   private function decodeImages():void {
var decoder:Base64Decoder = new Base64Decoder();
// imgData is the Base64 encoded image
decoder.decode(imgData);
var imgBA:ByteArray = decoder.toByteArray();
var loader:Loader = new Loader();
loader.loadBytes(imgBA);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
loaderCompleteHandler);
  }

   private function loaderCompleteHandler(evt:Event):void {
// display the image
db_img.source = evt.currentTarget.content as Bitmap;
   }

  ]]
 /mx:Script

mx:Image id=db_img /



- Original Message - 
From: Jon Santos [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Saturday, April 12, 2008 2:01 PM
Subject: Re: [flexcoders] How to download a BLOB from databaseusing Java


Hi Jim.i know how to get the image in my POJO.

The process i´m following:

I get the image form database throw my servlet. In this class i get the 
ImageObject (POJO), it means the image and other data.
In my FLEX application i have one object ImageObject (Action Script)like 
Remote Object for the java objectthen i able to get 
the image and the other data in my FLEX application

The unique problem i´m finding : I don´t know how to display in my FLEX 
application (it means your B question).i don´t know 
which component i must use to display my image (array of bytes).

Thanks in advanceand i hope u already understad my problem.




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



[flexcoders] How to download a BLOB from database....using Java

2008-04-11 Thread txakin
Hi all

I would like to know...how to download a BLOB (image, file...binary 
data) from my Oralce database to my Flex application.

I think i already have my servlet createdthe souce can be more 
or less like the next one:

Session session = HibernateSessionFactory.getSession();

//Here i get my POJO (my movieImage object)
MovieImage myMovieImage = (MovieImage)session.load(MovieImage.class, 
movieId);

//I got the binary data (in this case one image), into array of bytes
byte[] myCover = myMovieImage.getCover();
ServletOutputStream servletOutputStream = res.getOutputStream();
res.setContentType(application/image);
res.setContentLength(myCover.length);
servletOutputStream.write(myCover, 0, myCover.length);
servletOutputStream.flush();
servletOutputStream.close();


But my problem is how to show that image in my component

Can someone help me (with some source or with some steps or some 
example) to get the solution?

Thansk in advance.



RE: [flexcoders] How to download a BLOB from database....using Java

2008-04-11 Thread Jim Hayes

Is your question
a) how to get the byteArray into flex?
b) how to display it once it is in flex?
c) both a and b ?

I can help you with b !

-Original Message-
From: flexcoders@yahoogroups.com on behalf of txakin
Sent: Fri 11/04/2008 14:29
To: flexcoders@yahoogroups.com
Subject: [flexcoders] How to download a BLOB from databaseusing Java
 
Hi all

I would like to know...how to download a BLOB (image, file...binary 
data) from my Oralce database to my Flex application.

I think i already have my servlet createdthe souce can be more 
or less like the next one:

Session session = HibernateSessionFactory.getSession();

//Here i get my POJO (my movieImage object)
MovieImage myMovieImage = (MovieImage)session.load(MovieImage.class, 
movieId);

//I got the binary data (in this case one image), into array of bytes
byte[] myCover = myMovieImage.getCover();
ServletOutputStream servletOutputStream = res.getOutputStream();
res.setContentType(application/image);
res.setContentLength(myCover.length);
servletOutputStream.write(myCover, 0, myCover.length);
servletOutputStream.flush();
servletOutputStream.close();


But my problem is how to show that image in my component

Can someone help me (with some source or with some steps or some 
example) to get the solution?

Thansk in advance.



__
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please then delete the e-mail and do not disclose its contents to any 
person.
This email has been scanned for Primal Pictures by the MessageLabs Email 
Security System.
__winmail.dat