getthumbnailimage on image object

Posted by jmls on 17-Sep-2008 08:11

I'm trying to use the getthumbnailimage method on the image object

(http://msdn.microsoft.com/en-us/library/system.drawing.image.getthumbnailimage.aspx)

but I am stuck on the third parameter. In c#, it is used like this:

public bool ThumbnailCallback()

{

return false;

}

public void Example_GetThumb(PaintEventArgs e)

{

Image.GetThumbnailImageAbort myCallback =

new Image.GetThumbnailImageAbort(ThumbnailCallback);

Bitmap myBitmap = new Bitmap("Climber.jpg");

Image myThumbnail = myBitmap.GetThumbnailImage(

40, 40, myCallback, IntPtr.Zero);

e.Graphics.DrawImage(myThumbnail, 150, 75);

}

what would the equivalent ABL code look like ? I tried he following but get an error on the define for mycallback.

DEF VAR myCallback AS Image.GetThumbnailImageAbort .

DEF VAR myBitMap AS Bitmap.

DEF VAR myThumbNail AS image.

mycallback = new Image.GetThumbnailImageAbort(THIS-OBJECT:GetThumbnailImageAbort).

myBitmap = new Bitmap("Climber.jpg").

myThumbnail = myBitmap:GetThumbnailImage(

40, 40, myCallback, IntPtr:Zero).

Graphics:DrawImage(myThumbnail, 150, 75).

All Replies

Posted by Peter Judge on 17-Sep-2008 08:19

Just going on the code above, I'd expect that to be DEF VAR

myCallback AS Image.GetThumbnailImageAbort . mycallback = new

Image.GetThumbnailImageAbort(ThumbnailCallback). -- peter

Posted by jmls on 17-Sep-2008 08:23

Just going on the code above, I'd expect that to be

DEF VAR myCallback AS Image.GetThumbnailImageAbort .

mycallback = new

Image.GetThumbnailImageAbort(ThumbnailCallback).

my issue is the def var

DEF VAR myCallback AS Image.GetThumbnailImageAbort .

does not compile

Posted by Admin on 17-Sep-2008 08:29

Looks like an embedded type.

Try Image+GetThumbnailImageAbort as the type name. I had to find out the hard way, but the class browser also lists the type like that.

Posted by jmls on 17-Sep-2008 08:36

Looks like an embedded type.

Try Image+GetThumbnailImageAbort as the type name. I

had to find out the hard way, but the class browser

also lists the type like that.

ok, how on earth did you learn that ? From just the browser ? And where is the "+" thing documented ?

Posted by Admin on 17-Sep-2008 08:37

what would the equivalent ABL code look like ? I

tried he following but get an error on the define for

mycallback.

...

mycallback = new

Image.GetThumbnailImageAbort(THIS-OBJECT:GetThumbnailI

mageAbort).

Had a closer look at your code. I'd be more than surprised, if that's possible in 10.2A. That would be passing a method reference to a .NET method. I doubt that's possible.

>Under the hood

I can't image how the reference passed would look like either.

Message was edited by:

Mike Fechner

Posted by Admin on 17-Sep-2008 08:39

I guess when I tried hard to use one of my own .NET classes where I used embedded types. Don't remember how I found out. Took me a while. Can be that Shelley or Martha helped me out in the end or I found out in the class browser.

Posted by Simon de Kraa on 17-Sep-2008 08:42

And where is the "+" thing documented ?

Search for "Referencing inner classes".

Posted by Peter Judge on 17-Sep-2008 08:48

my issue is the def var

DEF VAR myCallback AS Image.GetThumbnailImageAbort .

does not compile

According to MSDN, Image.GetThumbnailImageAbort is a delegate, and the creation (NEW'ing) of these are not supported in the ABL (TTBOMK). The ABL way of dealing with them is through the Subscribe() method.

-- peter

Posted by Simon de Kraa on 17-Sep-2008 11:54

I tried your code and when I use NEW I get a "Progress Client has encountered a problem and needs to close." error...

So how is the Subscribe() supposed to work?

myCallBack:???:Subscribe(ThumbnailCallback).

METHOD PUBLIC LOGICAL ThumbnailCallback(INPUT sender AS CLASS System.Object):

RETURN FALSE.

END METHOD.

Posted by jmls on 17-Sep-2008 15:41

According to MSDN, Image.GetThumbnailImageAbort is a

delegate, and the creation (NEW'ing) of these are not

supported in the ABL (TTBOMK). The ABL way of dealing

with them is through the Subscribe() method.

How would I use the SUBSCRIBE method when it is a parameter (a callback) ? Or are you saying I can't do in ABL what the example is doing ? According to the docs for this

"GDI+ version 1.0, the delegate is not used. Even so, you must create a delegate and pass a reference to that delegate in this parameter."

It does compile if I pass ? as the parameter ...

Posted by Admin on 17-Sep-2008 15:51

According to MSDN, Image.GetThumbnailImageAbort is

a

delegate, and the creation (NEW'ing) of these are

not

supported in the ABL (TTBOMK). The ABL way of

dealing

with them is through the Subscribe() method.

How would I use the SUBSCRIBE method when it is a

parameter (a callback) ? Or are you saying I can't do

in ABL what the example is doing ? According to the

docs for this

I believe, that we must make a difference between delegates and events. A delegate is a type-safe function reference (function pointer). It's type-safe, so the parameters are well defined and well known. Delegates are part of events (event handler are passed as delegates), but delegates are not the same as events.

I expect that the ABL compiler only checks for events when validating the usage of a SUBSCRIBE method, not for delegates that are passed as parameters.

"GDI+ version 1.0, the delegate is not used. Even so,

you must create a delegate and pass a reference to

that delegate in this parameter."

It does compile if I pass ? as the parameter ...

Great. As the ? (= null value) matches every data type, the type safeness is not violated. In this case, it sounds like a legacy to me. Are you able to achieve what you tried to do or did it just compile?

Posted by jmls on 17-Sep-2008 15:54

slight veering off topic. Elsewhere in this code is code (c#)

AnimatedPropertySetting scaleChange = new AnimatedPropertySetting(

RadElement.ScaleTransformProperty,

new SizeF(1f, 1f),

5,

20

);

I converted this to ABL thus:

DEF VAR scaleChange AS AnimatedPropertySetting NO-UNDO.

scaleChange = new AnimatedPropertySetting(

RadElement:ScaleTransformProperty,

new SizeF(1, 1),

5,

20

).

first of all, should I declare a variable for the Size object, and second of all, what does 1f,1f mean ?

Posted by jmls on 17-Sep-2008 15:56

I expect that the ABL compiler only checks for events

when validating the usage of a SUBSCRIBE method, not

for delegates that are passed as parameters.

So, you can't do it.

Great. As the ? (= null value) matches every data

type, the type safeness is not violated. In this

case, it sounds like a legacy to me. Are you able to

achieve what you tried to do or did it just compile?

I'll let you know when I can stop the client from crashing when I click on an image (bug report raised)

Posted by Admin on 17-Sep-2008 15:59

1f means 1 as a float numeric value.

Similar difference than a 1 or 1.0 in ABL source code. One is an integer, the other one a decimal.

Posted by Simon de Kraa on 18-Sep-2008 01:22

And what about the CreateDelegate() method?

Pseudo:

DEF VAR myCallback AS Image+GetThumbnailImageAbort.

myCallBack:CreateDelegate(, "ThumbnailCallback").

myThumbnail = myBitmap:GetThumbnailImage(40, 40, myCallback, ?).

METHOD PUBLIC LOGICAL ThumbnailCallback(INPUT sender AS CLASS System.Object):

RETURN FALSE.

END METHOD.

Posted by jquerijero on 20-Nov-2009 16:24

I didn't see this earlier. However, if you are not concern about handling when the GetThumbnailImage fails, you can just send ? for the delegate parameter.

This is the minmum syntax;

mySmallImage = myBigImage:GetThumbnailImage(32, 32, ?, ?).

This thread is closed