Power Draw Questions

Started by
9 comments, last by Viperxxy 21 years, 2 months ago
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?
Advertisement
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.
Would be nice if you could post an example.

  // 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;  
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?
TCount is 4 because there are 4 textures, each may have one or more patterns. How do you load the image and what are texture sizes?

- Lifepower

[edited by - Lifepower on February 19, 2003 9:31:22 AM]
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.
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
I''ll check it out, although it''s pretty strange. Can you show an image demonstrating this problem?

- Lifepower
Lifepower,

Sorry, I was able to find the bug, it wasn''t in the LoadToBitmap procedure but in my own code. Sorry again about that!

Kornalius

This topic is closed to new replies.

Advertisement