Flash에서 POST를 이용하여 jpg 생성하는 방법
조건1. IIS설치 되어있어야함.
조건2. 저장되는 폴더는 공유되어 있어야함.
----------------------- Flash 부분----------------------
_root.snapPhoto.draw(_root.main_mc);
pixels = new Array();
xNum = 0;
function capStart() {
if (xNum<=640) {
for (yNum=0; yNum<480; yNum++) {
red = (_root.snapPhoto.getPixel32(xNum, yNum) >> 16 & 0xFF).toString(16);
//빨간색
green = (_root.snapPhoto.getPixel32(xNum, yNum) >> 8 & 0xFF).toString(16);
//녹색
blue = (_root.snapPhoto.getPixel32(xNum, yNum) & 0xFF).toString(16);
//파란색
if (red.length<2) {
red = "0"+red;
}
if (green.length<2) {
green = "0"+green;
}
if (blue.length<2) {
blue = "0"+blue;
}
tmp = red+green+blue;
pixels.push(tmp);
}
} else {
sendCap();
clearInterval(intervalId);
}
xNum++;
msg_txt.text = Math.floor(xNum/640*100)+"% 완료";
}
intervalId = setInterval(this, "capStart", 1);
function sendCap() {
//보내기
var output_lv = new LoadVars();
var result_lv = new LoadVars();
result_lv.onHTTPStatus = function(httpStatus:Number) {
this.httpStatus = httpStatus;
if (httpStatus<300) {
trace("sendOK");
msg1_txt.text = "사진을 성공적으로 등록하였습니다.";
_root.gotoAndStop(5);
sendLocal();
_root.closePop();
}
};
_root.filename = _root.fileCr();
output_lv.img = pixels.toString();
output_lv.imgName = _root.filename;
output_lv.rootUrlName = _root.rooturl;
output_lv.defaultUrlName = _root.defaulturl;
output_lv.backName = _root.bgAry[_root.bgNum];
output_lv.sendAndLoad("http://"+_root.baseUrl+"/photoImg.aspx",result_lv,"POST");
_root.rew_btn.onPress()
_root.main_mc.photo_mc.m_mc.filters = "";
_root.layerNum = 0;
_root.chageLayer();
}
----------------------- aspx 부분----------------------
<%@ Page Language="C#" ContentType="image/jpeg" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%
Response.Clear();
string imgData=Request["img"];
string imgName=Request["imgName"];
string rootUrl=Request["rootUrlName"];
String y = DateTime.Today.AddDays(0).ToString("yyy");
String md = DateTime.Today.AddDays(0).ToString("MMdd");
string defaultUrl=Request["defaultUrlName"];
int wid = 640;
int hei = 480;
string[] split = imgData.Split(new Char[] { ',' });
string str, strCut;
int loop = 0;
Bitmap bt1 = new Bitmap(wid, hei);
// 픽셀에 맞게 For 돌리기
for (int i = 0; i < wid; i++){
for (int j = 0; j < hei; j++){
int red = Int16.Parse(split[loop].Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
int green = Int16.Parse(split[loop].Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
int blue = Int16.Parse(split[loop].Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
bt1.SetPixel(i, j, Color.FromArgb(red, green, blue));
loop++;
//bt1.SetPixel(i, j, GetColor(strCut));
}
}
bt1.Save(@rootUrl + y + "\\" + md + "\\" + imgName +".jpg", ImageFormat.Jpeg);
bt1.Save(@defaultUrl+ imgName +".jpg", ImageFormat.Jpeg);
Response.End();
%>
'Dev > Flash' 카테고리의 다른 글
[AS3.0] SharedObject 사용하여 플래시저장 (0) | 2012.07.13 |
---|---|
[AS3.0] LocalConnection을 이용한 Flash Player간의 통신 2.0 -> 3.0 (0) | 2012.07.13 |
[IIS] 플래시로 c#활용하여 폴더생성 및 삭제 (0) | 2012.07.13 |
[AS3.0] 특정점 기준회전 (fl.motion.MatrixTransformer) (0) | 2012.01.04 |