ASP.net在后台获取FileUpload上传后的Flash文件的宽高??我的问题最牛逼,你们说是不!

lunar2008 2008-01-20 03:39:36
如提,我用fileupload控件上传了一个flash格式的a.swf文件,这时在后台(.cs文件中)请问如何得到它的宽度和高度,它和图片文件好像有很大区别~。。。
...全文
398 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
茻鄷 2008-10-22
  • 打赏
  • 举报
回复
mark
rxdlovewy 2008-08-26
  • 打赏
  • 举报
回复
有没有在后台上传Flash格式的代码 有的话请发到我的邮箱里 867548343@qq.com谢谢了。
kiyeer 2008-01-29
  • 打赏
  • 举报
回复
我就是用这个可以获得flash文件的高度和宽度啊。有什么问题?
lunar2008 2008-01-27
  • 打赏
  • 举报
回复
OK谢谢楼上的朋友啦,我找到过这方面的函数了,其实目的就是要获取上传flash文件的宽高,比如你放在网页上时它显示时不是距形的一个动画么,就是这个距形的宽高,我说的应该很好理解呀!
kiyeer 2008-01-22
  • 打赏
  • 举报
回复
可以用以下方法实现:
http://test.0579fw.com/mypane.aspx?down=ok&filepath=kiyeer%2f%bf%cd%bb%a7%c9%cf%b4%ab%2fManagedZLib.rar
下载上面的dll文件,放在项目的BIN文件中,并引用。
然后建立一个类flashinfo.cs:
内容如下:

using System;
using System.Collections;
using System.IO;
using System.Text;

namespace FW0579.CService
{
public class FlashInfo
{
private int width, height, version, frameCount, fileLength;
private float frameRate;
private bool isCompressed;
public bool founderr;
public string errmeg;

public FlashInfo(string filename)
{
if(!File.Exists(filename))
throw new FileNotFoundException(filename);
FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader reader = new BinaryReader(stream);
try
{
if(stream.Length < 8){
throw new ArgumentNullException();}
string flashMark = new string(reader.ReadChars(3));
if(flashMark != "FWS" && flashMark != "CWS"){
throw new ArgumentNullException();}
isCompressed = flashMark == "CWS";
version = Convert.ToInt32(reader.ReadByte());
fileLength = reader.ReadInt32();
byte[] dataPart = new byte[stream.Length - 8];
reader.Read(dataPart, 0, dataPart.Length);
MemoryStream dataStream = new MemoryStream(dataPart);
try
{
if(isCompressed)
{
ManagedZLib.ManagedZLib.Initialize();
ManagedZLib.CompressionStream zlibStream = new ManagedZLib.CompressionStream(dataStream, ManagedZLib.CompressionOptions.Decompress);
BinaryReader zlibReader = new BinaryReader(zlibStream);
MemoryStream memoryStreamDecompressed = null;
try
{
byte[] decompressedPart = new byte[fileLength - 8];
zlibReader.Read(decompressedPart, 0, decompressedPart.Length);
memoryStreamDecompressed = new MemoryStream(decompressedPart);
ProcessCompressedPart(memoryStreamDecompressed);
}
finally
{
if(memoryStreamDecompressed != null)
memoryStreamDecompressed.Close();
zlibReader.Close();
zlibStream.Close();
ManagedZLib.ManagedZLib.Terminate();
}
}
else
ProcessCompressedPart(dataStream);
}
finally
{
dataStream.Close();
}
}
finally
{
reader.Close();
stream.Close();
}
}

private void ProcessCompressedPart(MemoryStream stream)
{
BinaryReader reader = new BinaryReader(stream);
try
{
byte[] rect;
int nbits, totalBits, totalBytes;
nbits = reader.ReadByte() >> 3;
totalBits = nbits * 4 + 5;
totalBytes = totalBits / 8;
if(totalBits % 8 != 0)
totalBytes++;
reader.BaseStream.Seek(-1, SeekOrigin.Current);
rect = reader.ReadBytes(totalBytes);
frameRate = float.Parse(string.Format("{1}.{0}", reader.ReadByte(), reader.ReadByte()));
frameCount = Convert.ToInt32(reader.ReadInt16());
BitArray bits = new BitArray(rect);
bool[] reversedBits = new bool[bits.Length];
for(int i = 0 ; i < totalBytes ; i++)
{
int count = 7;
for(int j = 8 * i ; j < 8 * (i + 1) ; j++)
{
reversedBits[j + count] = bits[j];
count -= 2;
}
}
bits = new BitArray(reversedBits);
StringBuilder sbField = new StringBuilder(bits.Length);
for(int i = 0 ; i < bits.Length ; i++)
sbField.Append(bits[i] ? "1" : "0");
string result = sbField.ToString();
string widthBinary = result.Substring(nbits + 5, nbits);
string heightBinary = result.Substring(3 * nbits + 5, nbits);
width = Convert.ToInt32(FlashInfo.BinaryToInt64(widthBinary) / 20);
height = Convert.ToInt32(FlashInfo.BinaryToInt64(heightBinary) / 20);
}
finally
{
reader.Close();
}
}

private static long BinaryToInt64(string binaryString)
{
if(binaryString == null)
throw new ArgumentNullException();
long result = 0;
for(int i = 0 ; i < binaryString.Length ; i++)
{
result = result * 2;
if(binaryString[i] == '1')
result++;
}
return result;
}

public int Width
{
get
{
return this.width;
}
}

public int Height
{
get
{
return this.height;
}
}

public int FileLength
{
get
{
return this.fileLength;
}
}

public int Version
{
get
{
return this.version;
}
}

public float FrameRate
{
get
{
return this.frameRate;
}
}

public int FrameCount
{
get
{
return this.frameCount;
}
}

public bool IsCompressed
{
get
{
return this.isCompressed;
}
}
}
}


然后调用:
FlashInfo strFlash = New FlashInfo(strPath);
int flashWidth, flashHeight;
flashWidth = strFlash.Width;
flashHeight = strFlash.Height;
Animatrix 2008-01-21
  • 打赏
  • 举报
回复
确实是牛逼问题
这个没研究过。。。
Thie 2008-01-20
  • 打赏
  • 举报
回复
获得Flash舞台的大小?
没研究过。
LikeCode 2008-01-20
  • 打赏
  • 举报
回复
对flash知道的不多,但flash不是矢量的吗,这个应该没有象位图一样有宽高概念的吧,是不是?!
cherish024 2008-01-20
  • 打赏
  • 举报
回复
你这个问题本身和fieupload控件没有关系

只要考虑如何获取path上的文件宽高问题~~还有flash本来就是矢量,也没有个界限的高度和宽度~。。。

i0876 2008-01-20
  • 打赏
  • 举报
回复
这个还真没有研究过。

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧