How to convert byte array to image and display

I am writing an application that uses XPCOM and TagLib (http://
developer.kde.org/~wheeler/taglib.html) to read metadata from an mp3
file and display the information in a XUL user interface. Using
TagLib, I am able to retrieve album art as a char * byte array. How
would I convert this into a format that can be displayed by a XUL
image tag?

Thanks

Chris
0
Chris
9/17/2008 7:38:47 PM
mozilla.dev.tech.xpcom 1345 articles. 0 followers. Post Follow

3 Replies
1027 Views

Similar Articles

[PageSpeed] 20

Chris wrote:
> I am writing an application that uses XPCOM and TagLib (http://
> developer.kde.org/~wheeler/taglib.html) to read metadata from an mp3
> file and display the information in a XUL user interface. Using
> TagLib, I am able to retrieve album art as a char * byte array. How
> would I convert this into a format that can be displayed by a XUL
> image tag?

It depends on what your char* byte array contains.  If it contains raw 
RGBA data, you probably want to use a <canvas> instead and call 
putImageData instead (though this only works from JavaScript).

If your data is in some encoded image format, you probably want to use a 
data: URI instead.

-Boris
0
Boris
9/18/2008 4:06:32 AM
On Sep 17, 11:06=A0pm, Boris Zbarsky <bzbar...@mit.edu> wrote:
> It depends on what your char* byte array contains. =A0If it contains raw
> RGBA data, you probably want to use a <canvas> instead and call
> putImageData instead (though this only works from JavaScript).
>
> If your data is in some encoded image format, you probably want to use a
> data: URI instead.
>
> -Boris

Thanks for pointing me in the right direction. I was able to get
images to display using the data: URI. Unfortunately a data URI seems
to have a maximum size restriction. On some of the audio files I
tested, the embedded images were quite large (greater than 150 KB).
These images could not be displayed using a data: URI. Is there a way
to change the maximum size of a data: URI?

Chris
0
Chris
9/25/2008 4:02:05 PM
Chris wrote:
> Unfortunately a data URI seems
> to have a maximum size restriction.

There is no such restriction in Gecko, other than available system 
memory.  I just tested by creating a data: URI with about 200,000 
characters in it, and it works fine over here.

-Boris
0
Boris
9/25/2008 4:28:54 PM
Reply:

Similar Artilces:

displaying image in image control from byte array
I am using C#, ASP.net 2.0 and visual web developer 2005 I have loaded an image file and saved it in a byte array named byte[] imageData. Now I want to display this image file in an image control i.e MyImageControl Please tell me how can I do itUmair Khan JadoonBlog: www.technobuddy.net Take a Page (Image.aspx); in page_load render the  byte[] imageData using Response.BinaryWrite(imageData);and in your page where you are having the image conrol assign the imageUrl property of control as... <asp:Image ID="MyImageControl" runat="server" ImageU...

Uploaded Image convert from Byte array to SQLSerer Image?
I have an aspx page uploading an image file (typically jpeg) and I am going to store it into a SQL Server table (for security reasons). However, the table has a field called RawImage defined as DBType.Image I cannot see how to convert / take the uploaded image which exists in a byte array and store it into the DBType.image field. I get an error that the typre cannot be converted. Is there some way to do this? Many thanks j b furlong | crosswins Check out this article: http://www.codeproject.com/aspnet/simpleuploadimage.asp. It discusses this solution of storing images in a databa...

Convert byte array to image
I am trying to convert a byte array to an image for displaying on a page but currently receiving the following error; System.ArgumentException: Parameter is not valid   Stack trace; [ArgumentException: Parameter is not valid.]   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +1062667   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement) +12   _search.Page_Load(Object sender, EventArgs e) in D:\componentsuk1\search.aspx.vb:82   System.Web.UI.Control.On...

Display an image from a byte array?
Hi there,I have images saved in my database a byte array and I'm wondering how can i display these is an ASP.NET repeater control? Long story short, you have to create a separate ASP.NET page (called, say, ShowImage.aspx) that takes in the unique identifier for the database record, grabs its binary content, and squirts it out to the browser. For example, you'd view a particular image visiting ShowImage.aspx?ID=4.In any event, once you have this page created you could add an <asp:Image> control to your Repeater and set: ImageUrl='<%# Eval("ID", "ShowIma...

How to Convert Byte Array into Image Url
 Hi,    I am developing a simple application Image Zooming using ASP and C#.    In that I used treeview control to display images in different levels or sizes.    Here I am storing the images in database in byte format.    If I click on particular image I am displaying that in Imagebutton.    How can I get image path that is stored in database in byte format.    I want that image path from database.    Please anybody help me.Thanks in Advance look at image Grabber section in this a...

Image User Control
I created a user control that allows you to display a ByteArray in <img> tag like so...  <TRG:binaryimage ID="enrollment_Image" runat="server" FileName='<%# DataBinder.Eval(Container, "DataItem.FileName") %>' FileTypeID="1" Image='<%# DataBinder.Eval(Container, "DataItem.Image") %>' MaxWidth="175"  /> The user control takes the FileName and Image and stores it in a session variable. It then creates a url (displayimage.aspx?SessionID=randomtext) and adds it to an img tag. The displa...

Display bytes of array in a web page as image
 hi all,I have code like this in a windows application that displays bytes of array in a picture box. Code Snippet  1 private void DrawImage(Byte[] imgData, PictureBox picBox)2 {3 int colorval;4 Bitmap bmp = new Bitmap(m_ImageWidth, m_ImageHeight);5 picBox.Image = (Image)bmp;6 7 for (int i=0; i< bmp.Width; i++)8 {9 for (int j=0; j< bmp.Height; j++)10 {11 colorval = (int)imgData[(j*m_ImageWidth)+ i];12 bmp.SetPixel(i,j,Color.FromAr...

Display multiple image byte arrays on a single page
Dear all, I have an C# asp.net application that gets from the server images as byte arrays using a webservice (XML/SOAP). The xml webservice talk to a propriatary datastore and retreives the images.  As a result I usually get array object that has 10+(up to 20) individual byte arrays inside that represent 10 separate images. I would like to be able to show them on a single page as a thumbnail preview. And then if a click on a single thumbnal happens to request the full quality of that image back as a single image. At the moment i can write only one image using the Response.Wtit...

How to display byte array as an image (without a seperate page)
Hi, i was wondering how you display a byte array as an image on the page.  I have read the following article (http://www.odetocode.com/Articles/172.aspx) but from what i see they setup a seperate page to handle the image display.  I don't like this solution too much and wish to avoid doing this.  I created a method in my code behind: protected void DisplayImage(byte[] image){    Response.Clear();    Response.ContentType = "image/gif";    Response.BinaryWrite(image);    Response.End();}Then on my page i ...

How to convert object to Byte[] (Byte array)
Hello how are all here? I need to convert an object into byte[] (byte array). The line of code is below: byte[] DocImage = new byte[] DocImage = returnData["DocImage"] (which returns an object) Now How can I convert object to byte[]? There does not exist any built-in conversion from object to byte[] like Convert.ToInt32, Convert.ToString etc Thanks byte[] DocImage = new byte[] DocImage = (byte[] )returnData["DocImage"] Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like dup...

how to convert array of ansichar to array to byte?
Hi, I have a very hard time to convert array of ansichar to array to byte. I tried {code} arr: array[0..32767] of AnsiChar; bArr: TByteArray; move(arr, bArr, numBytesToRead); {code} and it doesn't work. they are array of 8 bit and I wonder what is the correct way to do this. Is there a way to cast this as well? I have search all over the internet and couldn't find any information about this. Could anybody help me? thanks alot, edwin chang wrote: > Hi, I have a very hard time to convert array of ansichar to array to byte. > I tried > > {code} ...

Images from Image folder to Byte array?
I can convert an image that is retrieved from a FileUpload object into a byte array and insert it into the database.. When the user signs-up i wish tosimply insert into the Picture (DB Type = Image) field to an image i already have saved in my images folder?Anyone know of a way to do this? Tutorials, articles or advise??! Here you go:http://davidhayden.com/blog/dave/archive/2006/05/19/2948.aspxWelcome to my SQL/ASPNET forum for Chinese http://51up.org/bbs/forumdisplay.php?fid=38...

Safe to convert int array into BYTE array?
It it safe to convert a *size_t* into a *BYTE* like I'm doing here? It seems to work fine. {code} size_t HELLO_WORLD[] = {0x48,0x65,0x6C,0x6C,0x6F,0x20,0x57,0x6F,0x72,0x6C,0x64}; size_t iSize = sizeof(HELLO_WORLD) / sizeof(size_t); BYTE * pArray = (BYTE *)malloc(iSize); for(size_t i = 0; i < iSize; i++) { pArray[i] = BYTE(HELLO_WORLD[i]); } {code} <Jason Goff> wrote in message news:400034@forums.embarcadero.com... > It it safe to convert a *size_t* into a *BYTE* like I'm doing here? It > seems to work fine. Yes, as long as none of the elemen...

display (byte type) image in image control..
Hi friends, Am fetching the image from DB in binary format. by selecting the image in dropdownlist, I wanna display it in image control. what should i do?  This is my code:protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {  int ImageID = DropDownList1.SelectedIndex; //Request.QueryString["img"] = ImageID.ToString();using (SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\WebserviceUpload2\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True&quo...

Web resources about - How to convert byte array to image and display - mozilla.dev.tech.xpcom

List of converts to Buddhism - Wikipedia, the free encyclopedia
Ajahn Brahm (born 1951), Religious teacher and student of the late Thai monk Ajahn Chah . Currently he is the abbot of the Bodhinyana Monastery, ...

Facebook Timeline For Pages: 8 Million Converts, 29 Million To Go
... reach to 98 percent of users who liked its page, as well as to double its engagement rate, during a 28-day period. Dr. Pepper hasn’t yet converted ...

Facebook stock roundup: Execs offload more stock, directors convert shares
... Bowles, the former co-chair of the now-defunct National Commission on Fiscal Responsibility and Reform, and Reed Hastings, Netflix CEO, converted ...

How to Convert Leads Into Buying Customers - The 9 Step Sales Process EVERYONE Should Use
... School of Business in Toronto on the topics of Sales and Entrepreneurship. I shared with them the sales process that I find How to Convert Leads ...

Bitcoin : Should I convert my savings to Bitcoin?
Answer (1 of 7): You should think of this question as "Should I invest all my savings in Bitcoin?", and not "Should I have my savings denominated ...

Coordinates - Calculate and Convert a Position on the App Store on iTunes
Get Coordinates - Calculate and Convert a Position on the App Store. See screenshots and ratings, and read customer reviews.

Catholics should not convert Jews, says Vatican, in push against anti-Semitism
... 50 years since the Vatican's repudiation of the concept of Jewish guilt for Jesus' death.  Vatican City: Catholics should not try to convert ...

Opinion: These 5 things made me a happy iPad Pro convert
... like I needed a bigger device. But after three weeks with my iPad Pro, several things have changed my mind, and I’m officially a happy convert ...

Today’s apps gone free: BlockBear, Stock Grader, PDF Smart Convert and more
Block ads and other annoying content, take the emotion out of investing, and convert almost anything into a PDF with todays collection of apps ...

Ford patents rear wheel that converts into a unicycle
Filed under: Government/Legal , Green , Ford , Green Driving , Motorcycle , Electric Ford is thinking about allowing drivers to remove a rear ...

Resources last updated: 1/2/2016 12:36:30 AM