Compare commits

...

3 Commits

Author SHA1 Message Date
nao@rist.u-tokai.ac.jp 0285f20848 working 32 and 64 fmx 3 years ago
nao@rist.u-tokai.ac.jp 3072c2525f 64bit setting wchar_t default 3 years ago
nao f6f52e7580 Merge branch 'vector' of nao/fmx-drag-and-drop into master 3 years ago
  1. 84
      AVIWrite.cpp
  2. 11
      AVIWrite.h
  3. 53
      Project1.cbproj
  4. 12
      Project1.cbproj.local
  5. 117
      Unit1.cpp
  6. 69
      Unit1.fmx
  7. 13
      Unit1.h
  8. 118
      aviimage.cpp
  9. 36
      aviimage.h
  10. 151
      extra/Unit1.cpp

@ -0,0 +1,84 @@
//---------------------------------------------------------------------------
#include <math.h>
#include <tchar.h>
#include <windows.h>
#include <vfw.h>
#pragma hdrstop
#include "AVIWrite.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#define LENG 10
#define PIXELS 100
#define WIDTH 160
#define HEIGHT 120
#define LINE ((((WIDTH)*24+31)&~31)/8)
#define SIZEIMAGE (LINE*(HEIGHT))
AVISTREAMINFO si={streamtypeVIDEO,comptypeDIB,0,0,0,0,
1,10,0,LENG,0,0,(DWORD)-1,0,{0,0,WIDTH,HEIGHT},0,0,_T("Video #1")};
BITMAPINFOHEADER bmih={sizeof(BITMAPINFOHEADER),WIDTH,HEIGHT,1,24,BI_RGB,
SIZEIMAGE,0,0,0,0};
//BYTE bBit[SIZEIMAGE];
PAVIFILE pavi;
PAVISTREAM pstm;
int line,sizeimage;
int AVIWritePrepare(int width,int height,int length, char* filename)
{
//memset(bBit,0,SIZEIMAGE);
//AVIFileInit();
si.dwLength = length;
si.rcFrame.left = 0; //{ 0,0,width,height};
si.rcFrame.top = 0;
si.rcFrame.right = width;
si.rcFrame.bottom = height;
bmih.biWidth = width;
bmih.biHeight = height;
line = ((width*24+31)&~31)/8;
sizeimage = line*height;
bmih.biSizeImage = sizeimage; // can be zero?
//AVIFileInit();
if (AVIFileOpen(&pavi,(LPCWSTR)filename,
OF_CREATE | OF_WRITE | OF_SHARE_DENY_NONE,NULL)!=0)
return 1;
if (AVIFileCreateStream(pavi,&pstm,&si)!=0)
return 1;
if (AVIStreamSetFormat(pstm,0,&bmih,sizeof(BITMAPINFOHEADER))!=0)
return 1;
return 0;
}
int AVIWriteaFrame(int i,char *buffer)
{
if( !buffer ){
//ShowMessage("buffer is invalid");
return 1;
}
if( AVIStreamWrite(pstm,i,1,buffer,sizeimage,
AVIIF_KEYFRAME,NULL,NULL)!=0)
return 1;
return 0;
}
int AVIWriteFinish(void)
{
AVIStreamRelease(pstm);
AVIFileRelease(pavi);
//AVIFileExit();
return 0;
}

@ -0,0 +1,11 @@
//---------------------------------------------------------------------------
#ifndef AVIWriteH
#define AVIWriteH
//---------------------------------------------------------------------------
#endif
int AVIWritePrepare(int width,int height,int length, char* filename);
int AVIWriteaFrame(int frame,char *buffer);
int AVIWriteFinish(void);

@ -6,7 +6,7 @@
<MainSource>Project1.cpp</MainSource> <MainSource>Project1.cpp</MainSource>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config> <Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform> <Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>3</TargetedPlatforms> <TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType> <AppType>Application</AppType>
</PropertyGroup> </PropertyGroup>
@ -75,6 +75,14 @@
<_TCHARMapping>wchar_t</_TCHARMapping> <_TCHARMapping>wchar_t</_TCHARMapping>
<Multithreaded>true</Multithreaded> <Multithreaded>true</Multithreaded>
<SanitizedProjectName>Project1</SanitizedProjectName> <SanitizedProjectName>Project1</SanitizedProjectName>
<AUP_ACCESS_COARSE_LOCATION>true</AUP_ACCESS_COARSE_LOCATION>
<AUP_ACCESS_FINE_LOCATION>true</AUP_ACCESS_FINE_LOCATION>
<AUP_CALL_PHONE>true</AUP_CALL_PHONE>
<AUP_CAMERA>true</AUP_CAMERA>
<AUP_INTERNET>true</AUP_INTERNET>
<AUP_READ_EXTERNAL_STORAGE>true</AUP_READ_EXTERNAL_STORAGE>
<AUP_WRITE_EXTERNAL_STORAGE>true</AUP_WRITE_EXTERNAL_STORAGE>
<AUP_READ_PHONE_STATE>true</AUP_READ_PHONE_STATE>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''"> <PropertyGroup Condition="'$(Base_Win32)'!=''">
<PackageImports>adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;RESTBackendComponents;RESTComponents;rtl;soapmidas;soaprtl;soapserver;svn;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports)</PackageImports> <PackageImports>adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;RESTBackendComponents;RESTComponents;rtl;soapmidas;soaprtl;soapserver;svn;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports)</PackageImports>
@ -136,7 +144,6 @@
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes> <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode> <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<LinkPackageImports>rtl.bpi;fmx.bpi</LinkPackageImports> <LinkPackageImports>rtl.bpi;fmx.bpi</LinkPackageImports>
<_TCHARMapping>char</_TCHARMapping>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
</PropertyGroup> </PropertyGroup>
@ -156,6 +163,14 @@
<BCC_PCHName_Clang>Project1PCH1.h</BCC_PCHName_Clang> <BCC_PCHName_Clang>Project1PCH1.h</BCC_PCHName_Clang>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<CppCompile Include="aviimage.cpp">
<DependentOn>aviimage.h</DependentOn>
<BuildOrder>3</BuildOrder>
</CppCompile>
<CppCompile Include="AVIWrite.cpp">
<DependentOn>AVIWrite.h</DependentOn>
<BuildOrder>4</BuildOrder>
</CppCompile>
<CppCompile Include="Project1.cpp"> <CppCompile Include="Project1.cpp">
<BuildOrder>0</BuildOrder> <BuildOrder>0</BuildOrder>
</CppCompile> </CppCompile>
@ -207,23 +222,24 @@
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'=='true'" LocalName="$(BDS)\bin\cc32c270mt.dll" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'!='true'" LocalName="$(BDS)\bin\cc32c270.dll" Class="DependencyModule">
<Platform Name="Win32"> <Platform Name="Win32">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx64\libcgstl.dylib" Class="DependencyModule"> <DeployFile LocalName=".\Win64\Debug\Project1.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="OSX64"> <Platform Name="Win64">
<RemoteName>Project1.exe</RemoteName>
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'!='true'" LocalName="$(BDS)\bin\cc32270.dll" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx32\libcgcrtl.dylib" Class="DependencyModule">
<Platform Name="Win32"> <Platform Name="OSX32">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx32\libcgcrtl.dylib" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx64\libcgstl.dylib" Class="DependencyModule">
<Platform Name="OSX32"> <Platform Name="OSX64">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
@ -232,6 +248,11 @@
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'!='true'" LocalName="$(BDS)\bin\cc32270.dll" Class="DependencyModule">
<Platform Name="Win32">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx32\libcgstl.dylib" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx32\libcgstl.dylib" Class="DependencyModule">
<Platform Name="OSX32"> <Platform Name="OSX32">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
@ -268,24 +289,18 @@
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile LocalName=".\Win32\Debug\Project1.tds" Configuration="Debug" Class="DebugSymbols">
<Platform Name="Win32">
<RemoteName>Project1.tds</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'=='true'" LocalName="$(BDS)\bin64\cc64270mt.dll" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'=='true'" LocalName="$(BDS)\bin64\cc64270mt.dll" Class="DependencyModule">
<Platform Name="Win64"> <Platform Name="Win64">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx64\libcgcrtl.dylib" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'=='true'" LocalName="$(BDS)\bin\cc32c270mt.dll" Class="DependencyModule">
<Platform Name="OSX64"> <Platform Name="Win32">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile Condition="'$(DynamicRTL)'=='true' And '$(Multithreaded)'!='true'" LocalName="$(BDS)\bin\cc32c270.dll" Class="DependencyModule"> <DeployFile Condition="'$(DynamicRTL)'=='true'" LocalName="$(BDS)\Redist\osx64\libcgcrtl.dylib" Class="DependencyModule">
<Platform Name="Win32"> <Platform Name="OSX64">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>

@ -7,10 +7,12 @@
<Transaction>2022/04/27 13:14:52.000.156,=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.cpp</Transaction> <Transaction>2022/04/27 13:14:52.000.156,=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.cpp</Transaction>
<Transaction>2022/04/29 11:55:29.000.785,=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.cpp</Transaction> <Transaction>2022/04/29 11:55:29.000.785,=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.cpp</Transaction>
<Transaction>2022/04/29 11:55:30.000.866,=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Project1PCH1.h</Transaction> <Transaction>2022/04/29 11:55:30.000.866,=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Project1PCH1.h</Transaction>
<Transaction>2022/04/29 12:01:48.000.306,C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.fmx=C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Unit1.fmx</Transaction> <Transaction>2022/04/29 12:01:48.000.306,C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Unit1.h=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.h</Transaction>
<Transaction>2022/04/29 12:01:48.000.306,C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.h=C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Unit1.h</Transaction> <Transaction>2022/04/29 12:01:48.000.306,C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Unit1.cpp=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.cpp</Transaction>
<Transaction>2022/04/29 12:01:48.000.306,C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.cpp=C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Unit1.cpp</Transaction> <Transaction>2022/04/29 12:01:48.000.306,C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Unit1.fmx=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Unit1.fmx</Transaction>
<Transaction>2022/04/29 12:01:51.000.704,C:\Users\nao\Documents\Embarcadero\Studio\Projects\Project1PCH1.h=C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Project1PCH1.h</Transaction> <Transaction>2022/04/29 12:01:51.000.704,C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Project1PCH1.h=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Project1PCH1.h</Transaction>
<Transaction>2022/04/29 12:01:53.000.604,C:\Users\nao\Documents\Embarcadero\Studio\Projects\Project1.cbproj=C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Project1.cbproj</Transaction> <Transaction>2022/04/29 12:01:53.000.604,C:\Users\nao\Documents\Embarcadero\Studio\Projects\kuse-dd\Project1.cbproj=C:\Users\nao\Documents\Embarcadero\Studio\Projects\Project1.cbproj</Transaction>
<Transaction>2022/05/22 05:59:25.000.227,=C:\Users\jakeb\Documents\Embarcadero\Studio\Projects\fmx-dd-alt\AVIWrite.cpp</Transaction>
<Transaction>2022/05/22 05:59:25.000.211,=C:\Users\jakeb\Documents\Embarcadero\Studio\Projects\fmx-dd-alt\aviimage.cpp</Transaction>
</Transactions> </Transactions>
</BorlandProject> </BorlandProject>

@ -8,6 +8,9 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include "aviimage.h"
#include "AVIWrite.h"
#include "Unit1.h" #include "Unit1.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -25,6 +28,13 @@
#endif #endif
std::vector <AnsiString>filenames; std::vector <AnsiString>filenames;
aviimage* work;
int iw,ih;
int start,fend;
void playbackavi(aviimage*,int,int);
void dispaframe(aviimage*, int);
TForm1 *Form1; TForm1 *Form1;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -63,12 +73,68 @@ void __fastcall TForm1::msg_hnd(TWMDropFiles Msg)
{ {
*/ */
void dispaframe(aviimage* avi,int framenum)
{
//TWICImage* twic = new TWICImage();
TImage* targeti;
TMemoryStream* temp = new TMemoryStream();
TBitmap* first = new TBitmap();
targeti = Form1->Image1;
//targeti->Picture->Bitmap->PixelFormat=pf24bit; // should be 8bit
targeti->Width = iw;
targeti->Bitmap->Width = iw;
targeti->Height=ih;
targeti->Bitmap->Height = ih;
first->Width = iw;
first->Height = ih;
Form1->Label1->Text = IntToStr(framenum);
avi->saveaframe(framenum,temp);
temp->Position = 0;
first->LoadFromStream(temp);
//targeti->Picture->Bitmap->LoadFromStream(temp);
Form1->Label2->Text = IntToStr(first->Width);
Form1->Label3->Text = IntToStr(first->Height);
Form1->Image1->Bitmap->Assign(first);
targeti->Repaint();
}
void playbackavi(aviimage* avi,int start, int end)
{
TImage* targeti;
TMemoryStream* temp = new TMemoryStream();
targeti = Form1->Image1;
//targeti->Bitmap->PixelFormat=pf24bit; // should be 8bit
targeti->Width = iw;
targeti->Bitmap->Width = iw;
targeti->Height=ih;
targeti->Bitmap->Height = ih;
for( int i = start ; i < end ; i++ ){
Form1->Label1->Text = IntToStr(i);
dispaframe(avi,i);
//Application->ProcessMessages();
//targeti->Refresh();
//Form1->Invalidate();
}
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam) LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{ {
int count; int count;
int i; int i;
char fname[256]; char fname[256];
TRect f;
if(Msg == WM_DROPFILES){ if(Msg == WM_DROPFILES){
@ -82,10 +148,38 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
//ドロップされたファイルの名前を取得する //ドロップされたファイルの名前を取得する
DragQueryFile((HDROP)wParam, i, filename.get(), length + 1); DragQueryFile((HDROP)wParam, i, filename.get(), length + 1);
AnsiString temp; UnicodeString temp;
temp = filename.get(); temp = filename.get();
//Form1->Memo1->Lines->Add(temp); //Form1->Memo1->Lines->Add(temp);
filenames.push_back(temp); //filenames.push_back(temp);
Form1->Memo1->Lines->Add(temp);
if( ExtractFileExt(temp) == ".avi" ){
work = new aviimage(temp.c_str());
//f = AVIImage1->Frame;
f = work->getframerect();
iw = f.Width();
ih = f.Height();
start = work->getfirst();
fend = work->getlast();
Form1->Memo1->Lines->Add("Avi file: "+AnsiString(iw)+"x"+AnsiString(ih));
Form1->Memo1->Lines->Add("start: " + IntToStr(start) + "to " + IntToStr(fend));
Form1->TrackBar1->Min = start;
Form1->TrackBar1->Max = fend;
dispaframe(work,start);
//playbackavi(work,start,fend);
//playbackavi(work,start,end);
//delete work;
}
else if( ExtractFileExt(temp) == ".roi" ){
Form1->Memo1->Lines->Add("Roi file");
}
else if( ExtractFileExt(temp) == ".bmp" ){
Form1->Image1->Bitmap->LoadFromFile(temp);
}
} }
@ -116,13 +210,22 @@ void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
SetWindowLongPtr(m_Hwnd,Parm,m_OldWndProc); SetWindowLongPtr(m_Hwnd,Parm,m_OldWndProc);
} }
void __fastcall TForm1::Button1Click(TObject *Sender)
void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{ {
// dump file names to Memo1 Label1->Text = IntToStr((int)TrackBar1->Value);
//using iterator Edit1->Text = IntToStr((int)TrackBar1->Value);
dispaframe(work,TrackBar1->Value);
}
//---------------------------------------------------------------------------
for( auto index = filenames.begin() ; index != filenames.end() ; index++ ) void __fastcall TForm1::Edit1Exit(TObject *Sender)
Memo1->Lines->Add(*index); {
Label1->Text = Edit1->Text;
TrackBar1->Value = StrToInt(Edit1->Text);
if( StrToInt(Edit1->Text) < fend )
dispaframe(work,StrToInt(Edit1->Text));
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

@ -2,8 +2,8 @@ object Form1: TForm1
Left = 0 Left = 0
Top = 0 Top = 0
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 480 ClientHeight = 683
ClientWidth = 640 ClientWidth = 806
FormFactor.Width = 320 FormFactor.Width = 320
FormFactor.Height = 480 FormFactor.Height = 480
FormFactor.Devices = [Desktop] FormFactor.Devices = [Desktop]
@ -13,19 +13,64 @@ object Form1: TForm1
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap] Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
DataDetectorTypes = [] DataDetectorTypes = []
Position.X = 64.000000000000000000 Position.X = 64.000000000000000000
Position.Y = 64.000000000000000000 Position.Y = 584.000000000000000000
Size.Width = 345.000000000000000000 Size.Width = 409.000000000000000000
Size.Height = 329.000000000000000000 Size.Height = 41.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 1 TabOrder = 1
Viewport.Width = 341.000000000000000000 Viewport.Width = 405.000000000000000000
Viewport.Height = 325.000000000000000000 Viewport.Height = 37.000000000000000000
end end
object Button1: TButton object Image1: TImage
Position.X = 496.000000000000000000 MultiResBitmap = <
Position.Y = 352.000000000000000000 item
end>
Position.X = 32.000000000000000000
Position.Y = 32.000000000000000000
Size.Width = 512.000000000000000000
Size.Height = 512.000000000000000000
Size.PlatformDefault = False
end
object TrackBar1: TTrackBar
CanParentFocus = True
Orientation = Horizontal
Position.X = 88.000000000000000000
Position.Y = 552.000000000000000000
Size.Width = 361.000000000000000000
Size.Height = 19.000000000000000000
Size.PlatformDefault = False
TabOrder = 3 TabOrder = 3
Text = 'Button1' OnChange = TrackBar1Change
OnClick = Button1Click end
object Edit1: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
TabOrder = 4
Position.X = 568.000000000000000000
Position.Y = 392.000000000000000000
OnExit = Edit1Exit
end
object Label1: TLabel
Position.X = 568.000000000000000000
Position.Y = 336.000000000000000000
Text = 'Label1'
TabOrder = 5
end
object Label2: TLabel
Position.X = 560.000000000000000000
Position.Y = 456.000000000000000000
Size.Width = 81.000000000000000000
Size.Height = 17.000000000000000000
Size.PlatformDefault = False
Text = 'Label2'
TabOrder = 6
end
object Label3: TLabel
Position.X = 632.000000000000000000
Position.Y = 456.000000000000000000
Size.Width = 81.000000000000000000
Size.Height = 17.000000000000000000
Size.PlatformDefault = False
Text = 'Label3'
TabOrder = 7
end end
end end

@ -13,16 +13,25 @@
#include <FMX.Types.hpp> #include <FMX.Types.hpp>
#include <FMX.Platform.Win.hpp> #include <FMX.Platform.Win.hpp>
#include <FMX.StdCtrls.hpp> #include <FMX.StdCtrls.hpp>
#include <FMX.Objects.hpp>
#include <FMX.Edit.hpp>
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class TForm1 : public TForm class TForm1 : public TForm
{ {
__published: // IDE で管理されるコンポーネント __published: // IDE で管理されるコンポーネント
TMemo *Memo1; TMemo *Memo1;
TButton *Button1; TImage *Image1;
TTrackBar *TrackBar1;
TEdit *Edit1;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
// void __fastcall FormDestroy(TObject *Sender); // void __fastcall FormDestroy(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall Button1Click(TObject *Sender); void __fastcall TrackBar1Change(TObject *Sender);
void __fastcall Edit1Exit(TObject *Sender);
//void __fastcall Button1Click(TObject *Sender);
private: // ユーザー宣言 private: // ユーザー宣言

@ -0,0 +1,118 @@
//---------------------------------------------------------------------------
/*
$Log: not supported by cvs2svn $
Revision 1.3 2005/03/08 05:55:08 nao
same strategy as aviimage using AVIStreamOpenFromFile instead of
AVIFileOpen and AVIFileGetStream for suppress of FD access?
*/
//#include <vcl.h>
#include <stdio.h>
#include <tchar.h>
#include <vfw.h>
#include "aviimage.h"
aviimage::aviimage()
{
AVIFileInit();
}
aviimage::aviimage(wchar_t* fname)
{
wVideo=~0;
AVIFileInit();
AVIStreamOpenFromFile(&pstm,fname,streamtypeVIDEO,0,OF_READ,NULL);
// AVIFileOpen(&pavi,fname,OF_READ | OF_SHARE_DENY_NONE,NULL);
// AVIFileOpen(&pavi,fname,OF_READ ,NULL);
// if (AVIFileInfo(pavi,&fi,sizeof(AVIFILEINFO))!=0)
// ShowMessage("AVIFileInfo error");
// for (dwStream=0;dwStream<fi.dwStreams;dwStream++) {
// if (AVIFileGetStream(pavi,&ptmp,0,dwStream)!=0)
// ShowMessage("");
// if (AVIStreamInfo(ptmp,&si,sizeof(AVISTREAMINFO))!=0)
// ShowMessage("");
// switch (si.fccType) {
// case streamtypeVIDEO:
// if (pstm==NULL || si.wPriority<wVideo) {
// if (pstm!=NULL)
// AVIStreamRelease(pstm);
// pstm=ptmp;
// wVideo=si.wPriority;
// }
// continue;
// }
// AVIStreamRelease(ptmp);
// }
// above code will not function in Windows XP
// it works in 95 and/or 98se mode only
//
// if(AVIFileGetStream(pavi,&pstm,streamtypeVIDEO,0)!=0)
// ShowMessage("AVIFileGetStream");
if (pstm==NULL)
ShowMessage("pstm NULL");
if ((pfrm=AVIStreamGetFrameOpen(pstm,NULL))==NULL)
ShowMessage("GetFrameOpen");
lStart=AVIStreamStart(pstm);
lEnd=AVIStreamLength(pstm)+lStart -1; // oops
if ((pbmih=(LPBITMAPINFOHEADER)AVIStreamGetFrame(pfrm,0))==NULL)
ShowMessage("GetFrame error");
frect.top = 0;
frect.left = 0;
frect.bottom = pbmih->biHeight-1;
frect.right = pbmih->biWidth-1;
}
void aviimage::saveaframe(long fnum, TMemoryStream* out)
{
BITMAPFILEHEADER bmfh;
if ((pbmih=(LPBITMAPINFOHEADER)AVIStreamGetFrame(pfrm,fnum))==NULL)
ShowMessage("GetFrame error");
bmfh.bfType=0x4d42;
bmfh.bfReserved1=bmfh.bfReserved2=0;
if (pbmih->biClrUsed==0)
switch (pbmih->biBitCount) {
case 1:bmfh.bfOffBits=sizeof(RGBQUAD)*2;break;
case 4:bmfh.bfOffBits=sizeof(RGBQUAD)*16;break;
case 8:bmfh.bfOffBits=sizeof(RGBQUAD)*256;break;
case 24:bmfh.bfOffBits=0;break;
case 16:
case 32:
bmfh.bfOffBits=pbmih->biCompression==BI_RGB?0:sizeof(DWORD)*3;
}
else
bmfh.bfOffBits=pbmih->biClrUsed*sizeof(RGBQUAD);
bmfh.bfOffBits+=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
bmfh.bfSize=bmfh.bfOffBits+(pbmih->biSizeImage==0
?((pbmih->biWidth*pbmih->biBitCount+31)&~31)/8*abs(pbmih->biHeight)
:pbmih->biSizeImage);
out->Write(&bmfh,sizeof(BITMAPFILEHEADER));
out->Write(pbmih,bmfh.bfSize-sizeof(BITMAPFILEHEADER));
out->Seek(0,soFromBeginning);
}
//---------------------------------------------------------------------------
void aviimage::finish()
{
if (AVIStreamGetFrameClose(pfrm)!=0)
ShowMessage("");
AVIStreamRelease(pstm);
AVIFileRelease(pavi);
AVIFileExit();
}

@ -0,0 +1,36 @@
#ifndef AVIIMAGEH
#define AVIIMAGEH
//#include <vcl.h>
#include <stdio.h>
#include <tchar.h>
#include <vfw.h>
class aviimage
{
AVIFILEINFO fi;
AVISTREAMINFO si;
CHAR szFile[MAX_PATH];
DWORD dwStream;
TRect frect;
LONG i,lStart,lEnd;
LPBITMAPINFOHEADER pbmih;
PAVIFILE pavi;
PAVISTREAM pstm,ptmp;
PGETFRAME pfrm;
WORD wVideo;
public:
aviimage();
aviimage(wchar_t* filename);
TRect getframerect() { return frect; }
long getfirst() { return lStart ; }
long getlast() { return lEnd; }
void saveaframe(long framenum, TMemoryStream* mem);
void finish();
};
#endif

@ -0,0 +1,151 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "aviimage.h"
#include "AVIWrite.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
aviimage* work;
int iw,ih;
int start,fend;
void playbackavi(aviimage*,int,int);
void dispaframe(aviimage*, int);
//---------------------------------------------------------------------------
void __fastcall TForm1::WMDROPFILES(TWMDropFiles Msg)
{
int i;
char buf[MAX_PATH];
TRect f;
//int iw,ih;
//ドラッグされたファイルの個数
int cnt=::DragQueryFile((HDROP)Msg.Drop,0xFFFFFFFF,NULL,0);
for(int i=0;i<cnt;i++){
::DragQueryFile((HDROP)Msg.Drop, i,buf,sizeof(buf));
// bufにファイル名が入っている
Memo1->Lines->Add(AnsiString(buf));
if( ExtractFileExt(buf) == ".avi" ){
work = new aviimage(buf);
//f = AVIImage1->Frame;
f = work->getframerect();
iw = f.Width();
ih = f.Height();
start = work->getfirst();
fend = work->getlast();
Memo1->Lines->Add("Avi file: "+AnsiString(iw)+"x"+AnsiString(ih));
Memo1->Lines->Add("start: " + IntToStr(start) + "to " + IntToStr(fend));
TrackBar1->Min = start;
TrackBar1->Max = fend;
dispaframe(work,start);
//playbackavi(work,start,fend);
//playbackavi(work,start,end);
//delete work;
}
else if( ExtractFileExt(buf) == ".roi" ){
Memo1->Lines->Add("Roi file");
}
else if( ExtractFileExt(buf) == ".bmp" ){
Image1->Picture->LoadFromFile(buf);
}
}
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
DragAcceptFiles(Handle,True);
Memo1->Lines->Clear();
}
//---------------------------------------------------------------------------
void dispaframe(aviimage* avi,int framenum)
{
//TWICImage* twic = new TWICImage();
TImage* targeti;
TMemoryStream* temp = new TMemoryStream();
TBitmap* first = new TBitmap();
targeti = Form1->Image1;
targeti->Picture->Bitmap->PixelFormat=pf24bit; // should be 8bit
targeti->Width = iw;
targeti->Picture->Bitmap->Width = iw;
targeti->Height=ih;
targeti->Picture->Bitmap->Height = ih;
first->Width = iw;
first->Height = ih;
Form1->Label1->Caption = IntToStr(framenum);
avi->saveaframe(framenum,temp);
temp->Position = 0;
first->LoadFromStream(temp);
//targeti->Picture->Bitmap->LoadFromStream(temp);
Form1->Label2->Caption = IntToStr(first->Width);
Form1->Label3->Caption = IntToStr(first->Height);
Form1->Image1->Picture->Bitmap->Assign(first);
targeti->Refresh();
}
void playbackavi(aviimage* avi,int start, int end)
{
TWICImage* twic = new TWICImage();
TImage* targeti;
TMemoryStream* temp = new TMemoryStream();
targeti = Form1->Image1;
targeti->Picture->Bitmap->PixelFormat=pf24bit; // should be 8bit
targeti->Width = iw;
targeti->Picture->Bitmap->Width = iw;
targeti->Height=ih;
targeti->Picture->Bitmap->Height = ih;
for( int i = start ; i < end ; i++ ){
Form1->Label1->Caption = IntToStr(i);
dispaframe(avi,i);
//Application->ProcessMessages();
//targeti->Refresh();
//Form1->Invalidate();
}
}
void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
Label1->Caption = IntToStr(TrackBar1->Position);
Edit1->Text = IntToStr(TrackBar1->Position);
dispaframe(work,TrackBar1->Position);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Exit(TObject *Sender)
{
Label1->Caption = Edit1->Text;
TrackBar1->Position = StrToInt(Edit1->Text);
if( StrToInt(Edit1->Text) < fend )
dispaframe(work,StrToInt(Edit1->Text));
}
//---------------------------------------------------------------------------
Loading…
Cancel
Save