Log in

View Full Version : DrawBitmap on TCanvas



LordJashin
03-01-2012, 06:35 AM
How would I set this up for a different application? Does anyone know where the text versions are of simba's .dll extensions? For Smart it works like this:

var
SMART_Canvas: TBitmap;
SMART_DebugSetup: Boolean;

(*
SMART_SetupDebug
~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure SMART_SetupDebug();

Declares the SMART_Canvas bitmap. Does not need to be called in scripts as it's
called in the SMART_ functions automatically.

.. note::

Author: Coh3n
Last Modified: Unknown

Example:

.. code-block:: pascal

if (not SMART_DebugSetup) then
SMART_SetupDebug();
*)
procedure SMART_SetupDebug();
begin
SmartSetDebug(True);
SMART_Canvas := TBitmap.Create;
SMART_Canvas.canvas.handle := SmartGetDebugDC;
SMART_DebugSetup := true;
end;

Then you can use Draw Bitmap:

CleanBMP := BitmapFromString(Area.X2-Area.X1, Area.Y2-Area.Y1, '');
DrawBitmap(CleanBMP, SMART_Canvas.Canvas, Area.X1, Area.Y1);

Just confused on setting the handle. Want to set it to a different application, not using smart. Ive tried this so far:

var
TB : TBitmap;

TB := TBitmap.Create;
FindAndSetTarget('Free', true);
TB.Canvas.Handle:= GetImageTarget;
GetClientDimensions(w, h);
DrawBitmap(Bmp, TB.canvas, w - 1, h - 1);

Brandon
03-01-2012, 07:21 AM
U can't do that.. There is a difference between drawing on smart and drawing on another application's canvas.

Smart is C++ and Java and when u call SmartGetDebugDC.. it returns the Canvas (which grabs the Device Context) and Upon destruction, the canvas returns the device context immediately after using it. When your drawing on smart, your creating a canvas on top of smart's RS Canvas so as to not colour the actual game canvas.

Essentially a DC (Device Context) is a graphics Object or GDI.
I don't think simba's capabilities expand as far as to grab Device contexts for you.. Yes Simba can create a Canvas but that canvas is for Simba and Smart alone.. In other words, it's internal. The bitmaps u create, they're not returning handles.. the handles are kept internally and the integers they return are indices i think.. or I could be wrong.

LordJashin
03-01-2012, 04:18 PM
U can't do that.. There is a difference between drawing on smart and drawing on another application's canvas.

Smart is C++ and Java and when u call SmartGetDebugDC.. it returns the Canvas (which grabs the Device Context) and Upon destruction, the canvas returns the device context immediately after using it. When your drawing on smart, your creating a canvas on top of smart's RS Canvas so as to not colour the actual game canvas.

Essentially a DC (Device Context) is a graphics Object or GDI.
I don't think simba's capabilities expand as far as to grab Device contexts for you.. Yes Simba can create a Canvas but that canvas is for Simba and Smart alone.. In other words, it's internal. The bitmaps u create, they're not returning handles.. the handles are kept internally and the integers they return are indices i think.. or I could be wrong.

Haha I was hoping for too much, be cool if I could draw on like firefox or somethin :D, thx for the info +1 for u

Brandon
03-01-2012, 04:21 PM
U can.. just gotta do it without simba.. Now I can't tell you how because I don't know how to do it in pascal(MAYBE a plugin?) but if u really really want to do it, AND want help from me then you'd have to know C++ and if u do, then I'll help u draw on firefox lol.

LordJashin
03-01-2012, 04:36 PM
U can.. just gotta do it without simba.. Now I can't tell you how because I don't know how to do it in pascal(MAYBE a plugin?) but if u really really want to do it, AND want help from me then you'd have to know C++ and if u do, then I'll help u draw on firefox lol. Lol you crack me up. Here's what I know. I learned C++ from website (http://www.cplusplus.com/doc/tutorial/). And about brain fried me. Found this, ever since then been looking into this. Lot easier to look at. C and C++ there's just so much going on. I know most of the basics, no error handling tho. Basics of the language. Once I looked at Windows API i sheet myself. I'm at school though I'll be on later pce out for now.
Edit: Sounds like a plan, really wanna draw on a game not just firefox tho. Just used it as an example :D

masterBB
03-01-2012, 04:40 PM
Lol you crack me up. Here's what I know. I learned C++ from website (http://www.cplusplus.com/doc/tutorial/). And about brain fried me. Found this, ever since then been looking into this. Lot easier to look at. C and C++ there's just so much going on. I know most of the basics, no error handling tho. Basics of the language. Once I looked at Windows API i sheet myself. I'm at school though I'll be on later pce out for now.
Edit: Sounds like a plan, really wanna draw on a game not just firefox tho. Just used it as an example :D

Firefox can be done through a plugin, a game is a lot harder. I don't think this will be good first c++ project, it will not be that easy... Good luck though.

Brandon
03-01-2012, 05:07 PM
He's right lol your going to get deep into either the Win32 API or Object & Memory handling..

LordJashin
03-01-2012, 08:13 PM
He's right lol your going to get deep into either the Win32 API or Object & Memory handling..
I understand some things, but there's always some code in there that throws me off. Or maybe it just looks too blocky, and jibberjabberish to me. The hardest thing I came across just with C++ was the Abstract Base classes. I wouldn't want to interface with an application, that would be too much work just to draw over it I would think.

This is how I'd want it, sounds easier too. Somehow draw over screen (like on a transparent app or something), but be able to click through it. Then you could make that "stay on top" then you'd be fine? For a game in window mode this would work easily enough, but might or might not for full screen mode idk. Then somehow port that over to Simba :tongue: so I wouldn't have to deal with C and C++ anymore :D, like have it in a DLL or something.

Mmmm now that I think about it. Is it possible to make a fully transparent full screen form in Simba??? Then do that and use Form text, or use TCanvas.:spongebob: P.S. this sounds much easier...
Edit: Then click through it somehow? Maybe port something for it. Yes I looked at Wizzup's page about porting stuff to Simba