First the standard notice: We’re talking about a prerelease beta. Anything can change till release. Big thanks to Embarcadero for giving us the permission to talk about this.
Guys you’ve been great in providing feedback. Imho, this is our role. That’s why please accept my public gratitude, even if I’m not related (in any way) with Embarcadero, because I think that only in this way we can advance further. And as a practical proof of this gratitude I’ll try to answer bellow to some of your questions raised in your comments. (Yep, I do read them). Of course, I’ll do this in the limits of my NDA and on a subjective basis (sorry) trying to answer to the questions which I think that are most important for the crowd. But let’s start…
About the historic moment
(many thanks to Alister Christie for the correction)
I realize now that I wasn’t quite clear. For me the historic moment was then when I realized that the team starts to get it. IOW, they doesn’t anymore try to feed us with different buzzwords (“Open ALM”, “Software Optimization Delivery”) which in my humble opinion are very good but perhaps it isn’t the right time now to deal with them and/or nobody asked for them and/or are implemented in, let’s say in a “very disputable” (TM) manner. (the Help for example – even if in D2009 things got (at least) acceptable). Instead, now they do the first concrete steps in the right direction to try to fulfill what the community really wants. Ok, there is room for improvement, but there is a concrete progress. And this is a historic moment for me. Not TIFF per se (we use LibTiff and we are quite satisfied with it, even if we’ll switch to WIC in D2010).
About Alpha Transparency
Sons, have a look: 😉
Ok, disregard for the moment the units opened in the IDE. Most probably we’ll have a separate post about some of them, especially about the
RTTI.Pas. Be merciful and patient with me.
In the Form Designer you see three images. A very nice one which represents a forest landscape. Another one which is a transparent PNG representing a Save metaphor from the new set of Icons shipped by default with RAD Studio D2010. And another one with the text Transparent Bitmap which is a transparent BMP made by yours truly in 5 minutes. So, the answer is yes, PNG and BMP with Alpha channel are supported in D2010.
Direct2D support in Delphi 2010
TCanvas is declared as
TCanvas = class(TCustomCanvas) because we have now in
TDirect2DCanvas = class(TCustomCanvas) //snipped //Attached GDI Resources FDC: HDC; FHwnd: HWND; FSubRect: TRect; FRenderTarget: ID2D1RenderTarget; FPenPos: TPoint; //snipped public class function Supported: Boolean; constructor Create(DC: HDC; SubRect: TRect); overload; constructor Create(Canvas: TCanvas; SubRect: TRect); overload; constructor Create(Handle : HWND); overload; destructor Destroy; override; function CreateBrush(Color: TColor): ID2D1Brush; overload; function CreateBrush(Bitmap: TBitmap): ID2D1Brush; overload; function CreateBrush(Colors: array of TColor; StartPoint, EndPoint: TD2D1Point2F): ID2D1Brush; overload; function CreateBrush(Colors: array of TColor; Center, Offset: TD2D1Point2F; RadiusX, RadiusY: Single): ID2D1Brush; overload; function CreateBitmap(Bitmap: TBitmap): ID2D1Bitmap; procedure BeginDraw; procedure EndDraw; procedure DrawEllipse(const Ellipse: TD2D1Ellipse); procedure DrawGeometry(Geometry: ID2D1Geometry); procedure DrawLine(Point0, Point1: TD2DPoint2f); procedure DrawRectangle(const Rect: TD2D1RectF); procedure DrawRoundedRectangle(const RoundedRect: TD2D1RoundedRect); procedure FillEllipse(const Ellipse: TD2D1Ellipse); procedure FillGeometry(Geometry: ID2D1Geometry); procedure FillRectangle(const Rect: TD2D1RectF); procedure FillRoundedRectangle(const roundedRect: TD2D1RoundedRect); // Override common functions from TCustomCanvas procedure Arc(X1: Integer; Y1: Integer; X2: Integer; Y2: Integer; X3: Integer; Y3: Integer; X4: Integer; Y4: Integer); override; procedure Chord(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); override; procedure FillRect(const Rect: TRect); override; procedure FrameRect(const Rect: TRect); override; procedure Ellipse(X1, Y1, X2, Y2: Integer); override; procedure Rectangle(X1, Y1, X2, Y2: Integer); override; procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer); override; procedure Draw(X, Y: Integer; Graphic: TGraphic); overload; override; procedure Draw(X, Y: Integer; Graphic: TGraphic; Opacity: Byte); overload; override; procedure StretchDraw(const Rect: TRect; Graphic: TGraphic); overload; override; procedure StretchDraw(const Rect: TRect; Graphic: TGraphic; Opacity: Byte); reintroduce; overload; procedure Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); override; procedure PolyBezier(const Points: array of TPoint); override; procedure Polygon(const Points: array of TPoint); override; procedure Polyline(const Points: array of TPoint); override; procedure LineTo(X, Y: Integer); override; procedure MoveTo(X, Y: Integer); override; procedure PolyBezierTo(const Points: array of TPoint); override; procedure Refresh; override; function TextExtent(const Text: string): TSize; override; procedure TextOut(X, Y: Integer; const Text: string); override; procedure TextRect(var Rect: TRect; var Text: string; TextFormat: TTextFormat = ); overload; override; procedure TextRect(Rect: TRect; X, Y: Integer; const Text: string); overload; override; // Operations from TCustomCanvas that are invalid on a TDirect2DCanvas procedure BrushCopy(const Dest: TRect; Bitmap: TBitmap; const Source: TRect; Color: TColor); override; procedure DrawFocusRect(const Rect: TRect); override; // Doesn't have a concept of XOR brushes/pens procedure FloodFill(X, Y: Integer; Color: TColor; FillStyle: TFillStyle); override; property RenderTarget : ID2D1RenderTarget read GetRenderTarget; property Brush: TDirect2DBrush read GetBrush write SetBrush; property Pen: TDirect2DPen read GetPen write SetPen; property Font: TDirect2DFont read GetFont write SetFont; end;
…where all the
D2D1 types and interfaces (and many more) are declared in
D2D1.Pas – where especially that
ID2D1Geometry called by
FillGeometry is quite interesting, believe me. 😉
And now a piece of code which has both sad and nice parts:
class function TDirect2DCanvas.Supported: Boolean; var LModule: HMODULE; LProc: Pointer; begin if FSupported = TUncertainState.Maybe then begin LModule := LoadLibrary(d2d1lib); if LModule > 0 then begin LProc := GetProcAddress(LModule, 'D2D1CreateFactory'); // Do not localize if Assigned(LProc) then FSupported := TUncertainState.Yes else FSupported := TUncertainState.No; FreeLibrary(LModule); end else FSupported := TUncertainState.No; end; Result := FSupported = TUncertainState.Yes; end;
Is nice because it has your implementation ideas with regard of the ‘delayed’ keyword.
It is sad because there is no support for Windows XP (fallback to GDI+ etc.). As you know Direct2D is officially shipped for Vista and Windows 7 but they’re thinking about it. But if you’d asking me, I don’t see it very soon…
More words about Touch & Gestures
Seeing your comments, I spoke with different guys with positions from different big big big companies (not to mention names here). Guys, these things are here to stay even if we like it or not. The game is over. Big book shops (perhaps you know which ones 😉 ), hospitals, hotels, shop chains, national railway companies, bars, casinos etc. are fully determined to implement these things. Now there are happening very intense researches in the domain of voice recognition (voice commands, voice to text etc.) which already is considered ‘reliable’ and in relatively short period of time will appear the first products targeted to the mass market (yeah, I know about ‘Dragon Natural Speaking’ but they have in mind something much broader).
Returning to our flock, perhaps is better to know that you can draw the shape of your gesture on a canvas:
you have in
procedure DrawGesture(ACanvas: TCanvas; const APoints: array of TPoint; AColor: TColor); overload; procedure DrawGesture(ACanvas: TCanvas; const APoints: array of TPoint; AColor: TColor; const AOffset: TPoint); overload; procedure DrawGesture(ACanvas: TCanvas; AGesture: TCustomGestureCollectionItem; AColor: TColor); overload; inline; procedure DrawGesture(ACanvas: TCanvas; AGesture: TCustomGestureCollectionItem; AColor: TColor; const AOffset: TPoint); overload; inline; function ScaleGesturePoints(const Points: array of TPoint; Size: Integer): TGesturePointArray;
Helping that the above information helps you, we will, basically, close now (for a while) the VCL chapter, – perhaps we’ll have tomorrow a post on a slightly different theme – following in the next week to speak about new Database / Communications Features in RAD Studio 2010.
As always your feedback is more than welcomed. 🙂 As you see above, we try to answer as much as we can in order to please you.