Skip to content

Instantly share code, notes, and snippets.

View ochilab's full-sized avatar

おちラボ ochilab

View GitHub Profile
@ochilab
ochilab / ShowSelectedImage.cpp
Last active December 18, 2015 18:59
multi-tiff イメージファイルから指定したページを表示する(C++/CLI)
private:void ShowSelectedImage( int page )
{
Graphics ^g1 = pictureBox1->CreateGraphics() ;
FileStream^ fs ;
fs = gcnew FileStream( tifName , FileMode::Open , FileAccess::Read ) ;
Image^ im = Image::FromStream( fs ) ;
FrameDimension ^fd = gcnew FrameDimension( im->FrameDimensionsList[0] ) ;
//Bitmap^ map ;
int fd_count = im->GetFrameCount( fd ) ;//ページ数
if( 1 <= page && page <= fd_count )//存在するページ数なら絵とページ数を変更
@ochilab
ochilab / CheckHLine.cpp
Last active December 18, 2015 18:59
画像の中の横の直線を調べる(レポートスキャンシステム用)
private: void CheckHLine( Bitmap^ map ) {
int i , j , k , x , y , bure ;
int zahyoux[2500] , zahyouy[2500] ;
int point ;
Color col0 , col1 , col2 , col3 , col4 , col5 , col6 ;
int count = 0 ;
System::Drawing::Pen myPen( System::Drawing::Color::Red , 5 ) ;
if( map->Height == 0 || map->Width == 0 )//絵が何もない 不要?
{
return ;
@ochilab
ochilab / CheckVline.cpp
Created June 21, 2013 06:28
縦の直線を調べる(レポートスキャンシステム用)
private: void CheckVline(Bitmap^ map)
{
int i , j , k , x , y , bure ;
int zahyoux[3600] , zahyouy[3600] ;
int point ;
Color col0 , col1 , col2 , col3 , col4 , col5 , col6 ;
int count = 0 ;
System::Drawing::Pen myPen( System::Drawing::Color::Red , 5 ) ;
if( map->Height == 0 || map->Width == 0 )//絵が何もない 不要?
{
@ochilab
ochilab / App.config.xml
Created June 21, 2013 06:42
AWSSDKをVisualStudioで使う際の設定
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="AWSAccessKey" value="ここにアクセスキーを書く"/>
<add key="AWSSecretKey" value="ここにシークレットキーを書く"/>
</appSettings>
</configuration>
@ochilab
ochilab / SocketClient.cpp
Created June 22, 2013 00:43
Socketでサーバに文字列とバイナリを送信するクライアントプログラム
private: System::Void SocketClient() {
Socket ^mySocket;
NetworkStream ^myStream;
StreamWriter ^myWriter;
BinaryWriter ^myBWriter;
IPAddress ^myAddress;
IPHostEntry ^myHostEntry;
int myPort;
int size;
int count;
@ochilab
ochilab / udpClient.cpp
Last active December 18, 2015 19:49
UDPクライアントのサンプル。非同期通信版(C++/CLI)
using namespace System::Net;
using namespace System::Net::Sockets;
usc = gcnew UdpStateClass();
Socket ^listener = gcnew Socket(AddressFamily::InterNetwork, SocketType::Dgram, ProtocolType::Udp);
usc->endPnt = gcnew IPEndPoint(IPAddress::Any, 11000);//
usc->udpClt = gcnew UdpClient(11000); //接続相手
usc->udpClt->BeginReceive(gcnew AsyncCallback(this,&Clientwww::Form1::receiveCallback),usc);
@ochilab
ochilab / Report.cs
Created June 24, 2013 05:16
レポート用紙スキャンシステムのデータクラス(C#版)
class Report {
//以下は科目IDを構成する
private string year; //年度
public string Year {
get { return year; }
set { year = value; }
}
private string term; //学期
@ochilab
ochilab / fileopen.cs
Last active December 18, 2015 21:29
オープンファイルダイアログを利用したファイル選択のサンプルです。このサンプルでは、tiffファイルを対象としています。
string tiffFileName;
//OpenFileDialogクラスのインスタンスを作成
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = @"C:\";
//[ファイルの種類]に表示される選択肢を指定する
//指定しないとすべてのファイルが表示される
ofd.Filter =
"tifファイル(*.tif)|*.tif";
@ochilab
ochilab / OpenTiffFile.cpp
Last active December 18, 2015 21:29
multi-tiff イメージファイルから指定したページを表示する(C#)
using System.IO;
using System.Drawing.Imaging;
int page = 2; //指定ページ
FileStream tifFS = new FileStream(tiffFileName, FileMode.Open, FileAccess.Read);
Image gim = Image.FromStream(tifFS);
FrameDimension gfd = new FrameDimension(gim.FrameDimensionsList[0]);
int allPageNumber = gim.GetFrameCount(gfd);//全体のページ数を得る
@ochilab
ochilab / showMessageBox.cs
Created June 24, 2013 07:01
メッセージボックスを表示する(C#)
DialogResult result = MessageBox.Show("このファイルを解析しますか?",
"質問",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button2);
//YESが押された場合
if (result == DialogResult.Yes) {