Forums

Welcome Guest Search | Active Topics | Members

MediaUnsupportedException error Options
sunil
Posted: Saturday, January 26, 2008 1:10:39 AM
Rank: Newbie
Groups: Member

Joined: 1/17/2008
Posts: 1
Points: 3
HI all i am using Graphics Mill to set a image in the psd file but i am getting error
when i reach this following code

Aurigma.GraphicsMill.Bitmap photo = new Aurigma.GraphicsMill.Bitmap(stream);




i am using the code

if (fpUplaodLogo.HasFile)
{
using (BinaryReader reader = new BinaryReader
(fpUplaodLogo.PostedFile.InputStream))
{
image = (byte[])(reader.ReadBytes
(fpUplaodLogo.PostedFile.ContentLength));
// SaveImage(image);
}
}

//byte[] data = (byte[])(["Photo"]);
System.IO.MemoryStream stream = new System.IO.MemoryStream();


int offset = 78;
stream.Write(image, offset, image.Length - offset);


try
{
Aurigma.GraphicsMill.Bitmap photo = new Aurigma.GraphicsMill.Bitmap(stream);

updatedLayers.Add("image", photo);
updatedLayers.Add("title1", txtComNm.Text);
updatedLayers.Add("title2", txtCompDesc.Text);
updatedLayers.Add("heading ", txtComNm.Text);

imgFastTrackPsd.Visible = true;
BitmapViewer1.Bitmap = RasterizePsd(Server.MapPath("/psdimage/Add2.psd"), updatedLayers);
}
catch (Aurigma.GraphicsMill.Codecs.MediaUnsupportedException)
{
updatedLayers.Add("title1", txtComNm.Text);
updatedLayers.Add("title2", txtCompDesc.Text);
updatedLayers.Add("heading ", txtComNm.Text);
updatedLayers.Add("subheading", txtCompDesc.Text);
updatedLayers.Add("salary-details", txtAbtUs.Text);
updatedLayers.Add("locations-details", txtLoc.Text);
// updatedLayers.Add("aboutus", txtAbtUs.Text);

updatedLayers.Add("keyrequirements-details", txtKeyRequirement.Text);
updatedLayers.Add("whyshouldyouapply-details", txtYApply.Text);
updatedLayers.Add("numberofpositions-details", txtNoPos.Text);

updatedLayers.Add("other-details", txtOthers.Text);
updatedLayers.Add("joborderdetails-details", txtJODet.Text);
imgFastTrackPsd.Visible = true;
BitmapViewer1.Bitmap = RasterizePsd(Server.MapPath("/psdimage/Spotlighter-Add2.psd"), updatedLayers);
}


my problem is that when i upload a jpg image i am getting MediaUnsupportedException error . any help most appreciated can u pls any one tell where i am worng

thanks and regards,
sunil T
Alex Kon
Posted: Saturday, February 02, 2008 12:38:59 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 386
Points: 403
Hello,

It is hard to debug code on the forum, but I will try :) I need some additional information, so could you answer the following questions:

1) On which line of the posted code exception is thrown? Here?
Code:
Aurigma.GraphicsMill.Bitmap photo =
       new Aurigma.GraphicsMill.Bitmap(stream);


2) Why do you cut off the first 78 bytes of the input stream?
Code:

image = (byte[])reader.ReadBytes(
       fpUplaodLogo.PostedFile.ContentLength);
...
System.IO.MemoryStream stream = new System.IO.MemoryStream();

int offset = 78;
stream.Write(image, offset, image.Length - offset);
...
Aurigma.GraphicsMill.Bitmap photo =
       new Aurigma.GraphicsMill.Bitmap(stream);


And I think that there should be MemoryStream.Seek() method call to move stream position to the begin of source data before Aurigma.GraphicsMill.Bitmap constructor call.


Best wishes, Alex.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.