Highlighted

Problem creating an image from bitmap

Explorer ,
Apr 05, 2016

Copy link to clipboard

Copied

Hello,

I'm developing an AIR application that takes an snapshot of my camera and upload it to my server.

I've got the following AS3 code:

viewer.smoothing = true;
viewer
.deblocking = 5;
viewer
.attachCamera(cam);
cam
.setQuality(0, 100);
cam
.setMode(1920, 1080, 24);
cam
.setKeyFrameInterval(10);
cam
.setMotionLevel(100);
cam
.setLoopback(false);
var bitmapData:BitmapData= new BitmapData(1920, 1080);
bitmapData
.draw(viewer);
var jpg:JPGEncoder = new JPGEncoder();
var myBytes:ByteArray = jpg.encode(bitmapData);
var request:URLRequest = new URLRequest(urlToCall);
request
.data = myBytes;
request
.method = URLRequestMethod.POST;
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
request
.requestHeaders.push(header);
var loader:URLLoader = new URLLoader();
loader
.addEventListener(Event.COMPLETE, onCertificateComplete);
loader
.load(request);

I've got the following C# code:

Stream rs = (Stream)context.Request.InputStream;
string destPath = "c:\\docs\\img.jpg";
FileStream fs = new FileStream(destPath, FileMode.Create);
byte[] byWork = new byte[2047];
int iWork;
do
{
      iWork
= rs.Read(byWork, 0, byWork.Length);
      fs
.Write(byWork, 0, iWork);
} while (iWork != 0);
fs
.Flush();
fs
.Close();
rs
.Close();

The problem is the resultant photo. It has a 1920x1080 canvas size, but my webcam image in the photo it's only 160x120px, and the other pixels are white.

What I'm doing wrong? My webcam accepts 1920x1080px of resolution. My viewer is a "Video" instance.


Could someone help me?

Kind regards

TOPICS
Development

Views

179

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Problem creating an image from bitmap

Explorer ,
Apr 05, 2016

Copy link to clipboard

Copied

Hello,

I'm developing an AIR application that takes an snapshot of my camera and upload it to my server.

I've got the following AS3 code:

viewer.smoothing = true;
viewer
.deblocking = 5;
viewer
.attachCamera(cam);
cam
.setQuality(0, 100);
cam
.setMode(1920, 1080, 24);
cam
.setKeyFrameInterval(10);
cam
.setMotionLevel(100);
cam
.setLoopback(false);
var bitmapData:BitmapData= new BitmapData(1920, 1080);
bitmapData
.draw(viewer);
var jpg:JPGEncoder = new JPGEncoder();
var myBytes:ByteArray = jpg.encode(bitmapData);
var request:URLRequest = new URLRequest(urlToCall);
request
.data = myBytes;
request
.method = URLRequestMethod.POST;
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
request
.requestHeaders.push(header);
var loader:URLLoader = new URLLoader();
loader
.addEventListener(Event.COMPLETE, onCertificateComplete);
loader
.load(request);

I've got the following C# code:

Stream rs = (Stream)context.Request.InputStream;
string destPath = "c:\\docs\\img.jpg";
FileStream fs = new FileStream(destPath, FileMode.Create);
byte[] byWork = new byte[2047];
int iWork;
do
{
      iWork
= rs.Read(byWork, 0, byWork.Length);
      fs
.Write(byWork, 0, iWork);
} while (iWork != 0);
fs
.Flush();
fs
.Close();
rs
.Close();

The problem is the resultant photo. It has a 1920x1080 canvas size, but my webcam image in the photo it's only 160x120px, and the other pixels are white.

What I'm doing wrong? My webcam accepts 1920x1080px of resolution. My viewer is a "Video" instance.


Could someone help me?

Kind regards

TOPICS
Development

Views

180

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 05, 2016 0
rewb0rn LATEST
Advocate ,
Apr 08, 2016

Copy link to clipboard

Copied

You should break the problem apart first. Have you tried adding the bitmapData to the stage to check the image at that point, before you encode and upload it?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 08, 2016 0