• ベストアンサー

このプログラムはどういう意味でしょうか??

var img_data = new Array(); for (var x = 0; x<bmpSnap.width; x++) { for (var y = 0; y<bmpSnap.height; y++) { var col = bmpSnap.getPixel(x, y); img_data.push(("000000"+col.toString(16)).substr(-6, 6)); FLASH8 WindowsXPを使ってます。

  • Flash
  • 回答数1
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
  • BlurFiltan
  • ベストアンサー率91% (1611/1754)
回答No.1

詳細はわかりませんが...。 bmpSnap という名の BitmapData クラスのインスタンス を, 1pxごとに左上からまず横方向に横幅分走査して色を取得し, その横方向が1行が終われば,1px y方向に下がって また1pxごとに横方向に走査して色を取得し, 最終的には bmpSnap の1pxごとの色を全て取得して, 配列 img_data の要素に代入して行くという内容のスクリプトです。 漠然としたことしかわかりませんが, 大きく言えばそういうことです。 getPixel (BitmapData.getPixel メソッド) http://livedocs.adobe.com/flash/8_jp/main/00001955.html

shun0331
質問者

お礼

ありがとうございました! 解決しました!

関連するQ&A

  • FLASHとPHPの連携について

    プログラミング初心者です。 いまポストカード作成システムを大学の課題で作っています。 環境はWindowsXP FLASH8Proです。 最後の保存するところで詰まっています。 現時点でできているところまでHPにアップしたので載せます。 ​http://www.geocities.co.jp/ysmnh028/otameshi.html​ URLより画像を読み込み最後に保存をしたくていろいろ調べていて、PHPと連携させてブラウザ上に新しいページで画像を生成し、それを右クリック⇒保存という形で保存できる事はわかりました。 SAVEボタンのASは以下のとおりです。 on (press) { // 保存用Bitmapを生成 var bmpSnap = new flash.display.BitmapData(300, 444, false); // 保存したいMovieClipをBitmapに描画する bmpSnap.draw(_root.photo_mc); // BitmapデータをRGB配列にする var img_data = new Array(); for (var x = 0; x<bmpSnap.width; x++) { for (var y = 0; y<bmpSnap.height; y++) { var col = bmpSnap.getPixel(x, y); img_data.push(("000000"+col.toString(16)).substr(-6, 6)); } } // データを送信 System.useCodepage = true; myLoader = new LoadVars(); myLoader.img_width = bmpSnap.width; // 画像幅 myLoader.img_height = bmpSnap.height; // 画像高さ myLoader.img_data = img_data.join(""); // 画像データ myLoader.send("snapshot.php", "_blank", "POST"); } PHP側は <?php // 送信データを取得 $img_data = $_POST['img_data']; $width = $_POST['img_width']; $height = $_POST['img_height']; $type = $_POST['img_type']; // IMAGE生成 $source_img = imagecreatetruecolor ($width, $height); // 背景色を生成 $bg_col = imagecolorallocate($source_img, 0xFF, 0xFF, 0xFF); $border_col = imagecolorallocate($source_img, 0x00, 0x00, 0x00); // イメージを描画 $p = 0; for ($x = 0; $x < $width ; $x++) { for ($y = 0; $y < $height ; $y++) { $rgb = hexdec(substr($img_data, $p, 6)); $p+=6; $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $col = imagecolorallocate($source_img, $r, $g, $b); imagesetpixel($source_img, $x, $y, $col); } } header("Content-Type: image/jpeg"); imagejpeg($source_img); exit; // JPEG出力 touch("test.jpg"); // まずは空ファイル生成 imagejpeg($source_img, "test.jpg"); // 画像を保存 header("Content-Type: image/jpeg"); readfile('test.jpg'); exit; ?> 以上です。 ローカルでためしたところ画像は表示されず、かわりに代替画像としてアドレスが表示されます。 考えられる原因はなんでしょうか?? よろしくお願いします。

    • 締切済み
    • PHP
  • IplImageをPictureBoxへ表示がうまくいきません。

    VC++にてOpenCVを使い画像処理を行っている者です。 処理後の画像をMFCで作成したPictureBoxに表示したいのですが、 IplImageからBmpへの変換がうまくいきません。 //--------------------------------------------------------------- IplImage *img; img = cvLoadImage(filename, 0); // 0: グレイスケールで読み込む cvThreshold(img,img, 70, 255, CV_THRESH_BINARY_INV);//二値化 char* ColorBuf = (char*)calloc( sizeof(char), img->width * img->height * 4 ); for( int y = 0; y < img->height; y++ ) { for( int x = 0; x < img->width; x++ ) { ColorBuf[ y * img->width * 4 + x * 4 + 0 ] = img->imageData[ y * img->widthStep + x * 3 + 0 ]; ColorBuf[ y * img->width * 4 + x * 4 + 2 ] = ColorBuf[ y * img->width * 4 + x * 4 + 1 ]= ColorBuf[ y * img->width * 4 + x * 4 + 0 ]; } } mbmp.CreateBitmap( img->width, img->height, 1, 32, ColorBuf ); free( ColorBuf ); ((CStatic*)GetDlgItem( IDC_IMGSRC ))->SetBitmap ( mbmp ); cvReleaseImage( &img ); } //--------------------------------------------------------------- 今はPictureBoxに3つ縦に画像が表示されてしまってます。 何か改善点などがありましたらよろしくお願いいたします。

  • 多重配列の検索方法

    配列内の要素が10個あって重複することがない下記のような配列があった場合。 150に一番近いものを検索したいのですが、ループせずに一発で健作する方法はありますでしょうか。 _array.push({ data:img,_speed:0}); _array.push({ data:img,_speed:31}); _array.push({ data:img,_speed:62}); _array.push({ data:img,_speed:93}); _array.push({ data:img,_speed:124}); _array.push({ data:img,_speed:155}); _array.push({ data:img,_speed:186}); _array.push({ data:img,_speed:217}); _array.push({ data:img,_speed:248}); _array.push({ data:img,_speed:279}); _array.push({ data:img,_speed:309}); _array.push({ data:img,_speed:338}); _array.push({ data:img,_speed:367});

    • ベストアンサー
    • Flash
  • ポップアップブロック付きのブラウザ(IE8)で、window.open

    ポップアップブロック付きのブラウザ(IE8)で、window.openをつかって小窓を二つ出したい。 表題の通り、ポップアップブロックに引っかかってしまい、2つの小窓が出せません。 現状は、1つだけ小窓が立ち上がる状態です。 理想のタイミングは、エンターページをクリックすると、window.openが実行され 2つの小窓が立ち上がるというのが理想です。 以下に現在のスクリプトをコピペ致します。 <script language="JavaScript"> moveTo(0,0); resizeTo(screen.width,screen.height); var g_pop01; var g_pop02; function open_pop(){ var w_Width1 = 280 var w_Width2 = 567 var w_Height1 = 540 var w_Height2 = 540 var w_space = 22 var x1 = (screen.availWidth - w_Width1 - w_Width2 - w_space)/2; var x2 = x1 + w_Width1 + w_space var y1 = (screen.availHeight - w_Height1)/2; var y2 = (screen.availHeight - w_Height2)/2; g_pop01 = window.open("left2.swf?nowX="+x1+"&nowY="+y1,"flash_pop1",'toolbar=0,menubar=0,scrollbars=no,resizable=no,width='+w_Width1+',height='+w_Height1+',left='+x1+',top='+y1); g_pop02 = window.open("right2.swf?nowX="+x2+"&nowY="+y2+"&guideX="+x1+"&guideY="+y1,"flash_pop2",'toolbar=0,menubar=0,scrollbars=no,resizable=no,width='+w_Width2+',height='+w_Height2+',left='+x2+',top='+y2); } </script> </head> <body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 scroll="no" bgcolor="#000000"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <form name="frm2"> <input type="Hidden" name="fov" value="0"> </form> <tr> <td align="center" valign="middle"> <table width="484" height="260" border="0"> <tr> <td><img src="img/logo_484x260_2.png" border="0" usemap="#Map" LANGUAGE=javascript onClick="open_pop()"> <map name="Map"> <area shape="rect" coords="4,2,480,254" href="index.html"> </map></td> </tr> </table> </td> </tr> </table> </body> </html>

  • pythonでのエラー

    Pythonで以下のコードを実行すると12行目に対して 「ValueError: cannot reshape array of size 12288 into shape (4096,1)」 と出るのですがどなたか原因わかるでしょうか? import cv2 import numpy as np img_in = cv2.imread("Parrots.bmp") cv2.imshow("input", img_in) # img_out = cv2.GaussianBlur(img_in, (3,3), 0) # cv2.imshow("Gaussian", img_out) height, width = 64, 64 img_out = cv2.resize(img_in, (height, width)) x = np.reshape(img_out, (width*height,1)) # 画像のベクトル化 H = np.zeros((width*height, width*height), np.float32) for i in range(width*height):     if i-width-1 >= 0 and i+width+1 <width*height:         H[i,i-width-1] = 1/16         H[i,i-width] = 2/16         H[i,i-width+1] = 1/16         H[i,i-1] = 2/16         H[i,i] = 4/16         H[i,i+1] = 2/16         H[i,i+width-1] = 1/16         H[i,i+width] = 2/16         H[i,i+width+1] = 1/16 y = np.matmul(H, x)       y = cv2.GaussianBlur(y, (3,3), 0) cv2.imshow("Gaussian", y) noise = np.random.normal(0, 1, y.shape) y = np.clip(y + noise, 0, 255).astype(np.uint8) gamma = 1e-3 x_estimate = np.linalg.solve(np.matmul(H.T, H) + gamma*np.identity(height*width), np.matmul(H.T, y)) cv2.imshow("x_estimate",x_estimate)

  • 画像の縦:横比を維持してリサイズ

    画像の縦:横比を維持してリサイズし表示したいのですが、ご指導よろしくお願い致します。 <?php $array_img = glob( '*.jpg'); for($i=0; $i<sizeof($array_img); $i++){ $array_img[$i] = ereg_replace("\n","",$array_img[$i]); $thumbHeight = round($height * THUMBNAIL_WIDTH/$width); print "<br style=\"border:1px solid #000000\"><img src=\"$array_img[$i]\" width=\"320\" height=\"340\"></br>"; } ?>

    • 締切済み
    • PHP
  • IplImageのBmp変換。

    いつもこちらでお世話になっております。 現在OpenCVをつかって画像処理を行なっています。言語はVC++です。 OpenCVで処理した画像をPictureBoxに表示させたいのですが、 うまく表示できません。 IplImageをBmpに変換させる部分がおかしいとは思うのですが… //-------------------------------------------------------- IplImage *img; img = cvLoadImage(filename, 0); // 0: グレイスケールで読み込む cvThreshold(img,img, 70, 255, CV_THRESH_BINARY_INV);//二値化 // ビットマップ用のカラーバッファ char* ColorBuf = (char*)calloc( sizeof(char), img->width * img->height * 4 ); for( int y = 0; y < img->height; y++ ) { for( int x = 0; x < img->width; x++ ) { // Blue ColorBuf[ y * img->width + x * 4 + 0 ] = img->imageData[ y * img->widthStep + x * 3 + 0 ]; // Green ColorBuf[ y * img->width + x * 4 + 1 ] = img->imageData[ y * img->widthStep + x * 3 + 1 ]; // Red ColorBuf[ y * img->width + x * 4 + 2 ] = img->imageData[ y * img->widthStep + x * 3 + 2 ]; } } mbmp.CreateBitmap( img->width, img->height, 1, 32, ColorBuf ); free( ColorBuf ); ((CStatic*)GetDlgItem( IDC_IMGSRC ))->SetBitmap ( mbmp ); myDC.CreateCompatibleDC(pDC); CBitmap *oldBMP = myDC.SelectObject(&mbmp); pDC->BitBlt(0,0,300,300,&myDC,0,0,SRCCOPY); myDC.SelectObject(oldBMP); cvReleaseImage( &img ); //----------------------------------------------- PictureBoxのリソースIDをIDC_IMGSRCに設定しています。 今はPictureBoxの上部に画像が4つ並んでしまっている状態です。 なにか改善すべきところがありましたらよろしくお願いいたします。

  • JQUERY slideshowについて

    slide-show.jsについての質問です。 ホームページのトップイメージにスライドショーで3枚の写真を動かしています。 で、トップページの写真を9枚にして、左3枚・真ん中3枚・右3枚というふうに動かしたいです。 トップイメージの写真(幅900px)3枚を トップイメージの写真(幅300px)×3を3枚スライドにする (意味不明ですか・・・) 下の#slideshow01を#slideshow02、#slideshow03に増やして、設置したら動きませんでした。 出来れば、右→真ん中→左がちょっと時差をつけてスライドして欲しいです。 写真の切り替えは、CSSのZーindexを使っています。 現在のHTML <div id='slideshow01'> <!--スライドショーの3枚ここ!--> <img src="upimg/results/flash_1.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_2.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_3.jpg" alt="" width="300" height="400" /> <!--スライドショーの3枚終わり--> </div> 求めるHTML <div id='slideshow01'> <!--スライドショーの3枚ここ!--> <img src="upimg/results/flash_1.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_2.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_3.jpg" alt="" width="300" height="400" /> <!--スライドショーの3枚終わり--> </div> <div id='slideshow02'> <!--スライドショーの3枚ここ!--> <img src="upimg/results/flash_4.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_5.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_6.jpg" alt="" width="300" height="400" /> <!--スライドショーの3枚終わり--> </div> <div id='slideshow03'> <!--スライドショーの3枚ここ!--> <img src="upimg/results/flash_7.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_8.jpg" alt="" width="300" height="400" /> <img src="upimg/results/flash_9.jpg" alt="" width="300" height="400" /> <!--スライドショーの3枚終わり--> </div> この js を使っています。 function slideSwitch() { var $active = $('#slideshow01 img.active'); if ( $active.length == 0 ) $active = $('#slideshow01 img:last'); var $next = $active.next().length ? $active.next() : $('#slideshow01 img:first'); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() { $active.removeClass('active last-active'); }); } $(function() { setInterval( "slideSwitch()", 4000 ); });

  • html内かscript内で画像出力。どちらが軽い

    ホームページの読み込みは、画像を使えば使うほど重くなってしまいます。 下記コードでは、(1)と(2)で1.jpg~5.jpgの画像をページに出力しています。 (1)はHTMLに、(2)はscript内に、 (1)と(2)では(2)の方がhtmlに<img src=".jpg" width="800" height="300"/> と書かなかった分、ページが重くならない、ということになりますか? <html> <head> <title>HTML上に直接imgを出力した場合</title> </head> <body> <img src="1.jpg" width="800" height="300"/> <img src="2.jpg" width="800" height="300"/> <img src="3.jpg" width="800" height="300"/> <img src="4.jpg" width="800" height="300"/> <img src="5.jpg" width="800" height="300"/> </body> </html> <html> <head> <title>HTML上にはimgを出力せず、script内でimgを出力した場合</title> <script language="JavaScript"> var imgSanple = new Array( "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"); var randomSelect = Math.floor((Math.random() * 100)) % imgSanple.length; var i = "<img src='"+imgSanple[randomSelect]+"' width='800' height='300'>"; document.write(i); // --> </script> </head> <body> <noscript> <img src="1.jpg" width="800" height="300"> </noscript> </body> </html>

  • 細線化のプログラム

    細線化のプログラム C#で細線化のプログラムを作成してみましたがうまくいきません。 http://imagingsolution.blog107.fc2.com/blog-entry-138.html を参考に作成しました。 うまくいかないところは、一部に縦線がいくつも残ってしますところです。 ソース static Bitmap Shape(Bitmap bmp) { int Flag = 0; //初期化 for (int j = 0; j < bmp.Height ; j++) { for (int i = 0; i < bmp.Width ; i++) { if (bmp.GetPixel(i, j).R != 255) { bmp.SetPixel(i, j, Color.FromArgb(0, 0, 0)); } } } while(true){ //パターン1 for (int i = 1; i < bmp.Width - 1; i++) { for (int j = 1; j < bmp.Height - 1; j++) { if (bmp.GetPixel(i, j).R == 255) { //除去しないパターン if (( 略 )) { //セーフ } else if ((略)){ //セーフ } //除去するパターン else if ((bmp.GetPixel(i + 1, j).R != 255) || (bmp.GetPixel(i, j - 1).R != 255)) { //黒にする bmp.SetPixel(i, j, Color.FromArgb(0, 0, 0)); Flag++; } } } } // MessageBox.Show(Flag.ToString()); //終了 if (Flag == 0) return bmp; Flag = 0; /*パターン2も同じようにする*/ という感じでプログラムを組んでいます。 画像は失敗例です。アドバイスをお願いします

    • 締切済み
    • CGI

専門家に質問してみよう