Archived

This topic is now archived and is closed to further replies.

Power Draw Questions

This topic is 5399 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been using PowerDraw for quite some time and must say that it rocks. Now to my Questions. 1) Is it possible to use PD in windowed mode without useing the whole form? 2)If not, how do I display Pictures like the VTD-Tool does?

Share this post


Link to post
Share on other sites
1) No, Direct3D uses the whole form.
2) VTDTool displays these images using API BitBlt call. It loads them from VTD, directly writing to Bitmap instead of AGFImage. If needed, I could post the example code on how to do that.

Share this post


Link to post
Share on other sites

  
// stripped MakePreview method of VTD tool

// this file requires PStHandle library included

// (it comes with PowerDraw)


procedure LoadToBitmap();
var
Source, Read, Dest: Pointer;
SourceSize, TWidth, THeight, TCount, Res,
PatWidth, PatHeight: Integer;
Sig, i, j: Integer;
begin
Res:= VTDb.ReadRecord(Key, Source, SourceSize);
if (Res <> 0) then
begin
MessageDlg(''Error loading record ['' + IntToStr(Res) + '']'', mtError, [mbOk], 0);
Exit;
end;

Read:= Source; // pointer to texture data


// data signature

Sig:= ReadInt(Read);
if (Sig <> $58464741) then
begin
FreeMem(Source);
MessageDlg(''Invalid signature'', mtError, [mbOk], 0);
Exit;
end;

TWidth:= ReadInt(Read); // texture width

THeight:= ReadInt(Read); // texture height

PatWidth:= ReadInt(Read); // pattern width

PatHeight:= ReadInt(Read); // pattern height

TCount:= ReadInt(Read); // texture count


for i:= 0 to TCount - 1 do
begin
// read next texture

Bitmap:= TBitmapEx.Create();
Bitmap.Width:= TWidth;
Bitmap.Height:= THeight;
Bitmap.PixelFormat:= pf32bit;

for j:= 0 to THeight - 1 do
begin
Read:= Pointer(Integer(Source) + 24 + (j * TWidth * 4) + (i * TWidth * THeight * 4));
Dest:= Bitmap.ScanLine[J];
Move(Read^, Dest^, TWidth * 4);
end;

// here you can do something with the loaded texture


Bitmap.Free();
end;
FreeMem(Source);
end;

Share this post


Link to post
Share on other sites
I''ve tried to do load the patterns of an image in the vtd-file using your method, lifepower. but when my image for example is 64*64 px and a pattern is 16*16 px then it always only loads 4 images instead of 16. Tcount also has the value 4. what I do is, where ''// here you can do something with the loaded texture'' comment is, I add thc current image to an imagelist using imagelist.addmasked.
but there always is just the first row of patterns loaded.
can you help me?

Share this post


Link to post
Share on other sites
my code looks like this:


  
procedure LoadToBitmap();
var Source,Read,Dest:Pointer;
Sourcesize,TWidth,THeight,Tcount, res, PatWidth, PatHeight: integer;
Sig, i, j: integer;
bitmap: TBitmap;
begin
// Res := form1.VTDb1.ReadRecord(map.Dtileset.vtdkey, source, sourcesize);

Res := form1.VTDb1.ReadRecord(''ITS_room'', source, sourcesize);
if Res <> 0 then
begin
showmessage(''Vtd-Error: ''+inttostr(res));
exit;
end;

Read := SOurce;

Sig := ReadInt(read);
if SIg <> $58464741 then
begin
Freemem(source);
showmessage(''invalid signature'');
exit;
end;

TWidth := ReadInt(read);
Theight := ReadInt(read);
Patwidth := ReadInt(read);
PatHeight := ReadInt(read);
TCount := ReadInt(read);

for i:= 0 to TCount -1 do
begin
Bitmap := TBitmap.create();
bitmap.Width := TWidth;
bitmap.Height := THeight;
bitmap.PixelFormat := pf32bit;

for j:= 0 to THeight - 1 do
begin
Read:= Pointer(Integer(Source)+24+(j*TWidth*4)+(i*TWidth*THeight*4));
Dest := Bitmap.ScanLine[j];
Move(Read^,Dest^,TWidth *4);
end;

form2.ImageList1.AddMasked(bitmap,clolive);
Bitmap.Free();

end;
end;


the texturesize that is defined in the vtd for the image is 64*64. patterns are 16*16.

Share this post


Link to post
Share on other sites
Hi LifePower,

Using this LoadToBitmap function, the result is a black and white image without colours. Could you check and let us know? Even a pixel to pixel transfer doesn''t work, it''s still black & white.

Thanks in advance,
Kornalius

Share this post


Link to post
Share on other sites