마음의 안정을 찾기 위하여 - TStreamAdapter의 개선 코드(?)
2278103
811
743
관리자새글쓰기
태그위치로그방명록
별일없다의 생각
dawnsea's me2day/2010
색상(RGB)코드 추출기(Color...
Connection Generator/2010
최승호PD, '4대강 거짓말 검...
Green Monkey**/2010
Syng의 생각
syng's me2DAY/2010
천재 작곡가 윤일상이 기획,...
엘븐킹's Digital Factory/2010
TStreamAdapter의 개선 코드(?)
Delphi | 2007/11/08 18:33



TStreamAdapter를 상송받아 생성된 TCFStreamAdapter

type
TCFStreamAdapter = class(TStreamAdapter)
public
  function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; override; stdcall;
end;

function TCFStreamAdapter.Stat(out statstg : TStatStg; grfStatFlag : Integer): HResult;
begin
  result := inherited Stat(statstg, grfStatFlag);
  statstg.pwcsName := nil;
end;


응용 예]

procedure LitEtEcritResStream(var Image : TGPBitmap; NomRes, ResType : string);
var
  Res : TResourceStream;
  StreamInf :IStream;

begin
  Res := TResourceStream.Create(hInstance, NomRes, PChar(ResType));
  StreamInf := TCFStreamAdapter.Create(Res);
  try
    Image := TGPBitmap.Create(StreamInf);
  finally
    StreamInf := nil;
  end;
  Res.Free;
end;





Use the overriden TStreamAdapter :

type
TCFStreamAdapter = class(TStreamAdapter)
public
  function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; override; stdcall;
end;

In your Code :

LIStream := TCFStreamAdapter.Create(LStream);

But in your code :

LStream:= TMemoryStream.Create;
LIStream := TStreamAdapter.Create(LStream);
LStream.LoadFromFile('C:\InputFile.emf');

if you do this instead, does it works ? :

LStream:= TMemoryStream.Create;
LStream.LoadFromFile('C:\InputFile.emf');
LIStream := TStreamAdapter.Create(LStream);


 
실질적으로 위의 코드를 사용하게 된 계기는 GDIPLUS를 이용해 어떤 프로그램을 만들게 되면서이다. GDIPLUS에서 TGpImage 객체를 Create할때, 직접 로컬 이미지 파일 경로를 넣어주거나, ISTREAM을 넣어주게 되있는데, 로컬 파일을 사용할때마다 불러오는게 그다지 맘에 들지 않았고, 이미지에 변화를 주고자 할때 GDIPLUS 자체보다는 TBItmap객체를 직접 컨트롤 하는게 아직은 익숙해서 TBitmap을 Stream에 저장하고 이를 다시 IStream으로 변환하여 TGpImage로 생성하는 과정을 거쳤다.

    LStream  := TMemoryStream.Create;
    LIStream := TCFStreamAdapter.Create(LStream);
    LStream.LoadFromFile(strMapFn);

    Map_Image := TGpImage.Create(LiStream);

실질적으로 국내 델파이 관련 포털사이트 질답란등을 살펴보면, TStreamAdapter에 문제가 있다는 말이 있었고, 이때문에 대안 방안을 찾다가 http://www.progdigy.com의 질답란에서 발췌하게 되었다.
2007/11/08 18:33 2007/11/08 18:33
Article tag list Go to top
View Comment 0
Trackback URL :: 이 글에는 트랙백을 보낼 수 없습니다
 
 
 
 
: [1] ... [681][682][683][684][685][686][687][688][689] ... [1317] :
«   2024/04   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
전체 (1317)
출판 준비 (0)
My-Pro... (41)
사는 ... (933)
블로그... (22)
My Lib... (32)
게임 ... (23)
개발관... (3)
Smart ... (1)
Delphi (93)
C Builder (0)
Object... (0)
VC, MF... (10)
Window... (1)
Open API (3)
Visual... (0)
Java, JSP (2)
ASP.NET (0)
PHP (5)
Database (12)
리눅스 (29)
Windows (25)
Device... (1)
Embedded (1)
게임 ... (0)
Web Se... (2)
Web, S... (21)
잡다한... (6)
프로젝트 (0)
Personal (0)
대통령... (13)
Link (2)