[SOLVED] Fortes4Lazarus + TRLBarcode + Failed to create handles lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- paweld · 2010-08-26 14:07 Hi, When application work on remote desktop (remote desktop connection, not vnc) then I get error: Flailed to create handles. Only if barcode put on report. On local computer it's ok. Lazarus 0.9.29 r27128, fortes323forlaz Sorry for my english. Best regards paweld ---------------------------------------------------------------------- fabienwang · 2010-08-26 14:22 There is a newer version of this, could you try to upgrade fortes324forlaz ? http://sourceforge.net/projects/fortes4lazarus/ And try again. ---------------------------------------------------------------------- paweld · 2010-08-26 14:48 Quote from: Dr4x on August 26, 2010, 04:22:19 pmhttp://sourceforge.net/projects/fortes4lazarus/ I tried on this version and svn. It is the same. Best regards paweld ---------------------------------------------------------------------- neobrasil08 · 2010-08-30 02:23 Hi paweld, remote desktop connection on windows XP ou server? I have minimum experience on windows, i am user linux. Please, continue on fortes323forlaz. Fortes324 has a bug. Please try call only the report module isolated and send the result to me ok. Sorry for my english. ---------------------------------------------------------------------- paweld · 2010-08-30 12:49 Hi neobrasil08, Thanks for your interest. I tried on XP, Windows Server 2003, 2008, 2008R2 32-bit and 64-bit. The effect was the same. At this time, tracked down an error. Error is generated by the function RotatedBitmap (lines 679-704 in unit rlutils.pas). I comment line 836 (procedure InternalPaint) and 891 (procedure InternalPrint) - currently do not need this functionality. Unfortunately, faced a problem with the print / preview on the remote desktop instead of the barcode printed in black rectangle (the same happens when TRLImage). At desinger barcode and image looks good, but on print or preview, in the place of these components, You can see black rectangles. Sorry for my (Google Translate  ) bad english. Best regards paweld ---------------------------------------------------------------------- paweld · 2010-09-02 20:56 Hi, Both problems solved. Problems arose from the color depth on Windows (on local computer too). Problems occurred ("Failed to create handles" and the black blocks instead of the barcode, image, anglelabel) where the depth was less than 24bit. I changed the procedure RotateBitmap(aSource,aDest:Graphics.TBitmap; aAngle:double; aAxis,aOffset:TPoint). Before changes: Code: [Select]procedure RotateBitmap(aSource,aDest:Graphics.TBitmap; aAngle:double; aAxis,aOffset:TPoint); var   x            :integer;   xDest        :integer;   xOriginal    :integer;   xPrime       :integer;   xPrimeRotated:integer;   //   y            :integer;   yDest        :integer;   yOriginal    :integer;   yPrime       :integer;   yPrimeRotated:integer;   //   Radians      :double;   RadiansCos   :double;   RadiansSin   :double;   NormalImg    :TLazIntfImage;   RotateImg    :TLazIntfImage; begin   // create intermediary images   NormalImg := aSource.CreateIntfImage;   RotateImg := TLazIntfImage.Create(aDest.Width, aDest.Height);   RotateImg.DataDescription := NormalImg.DataDescription;   RotateImg.SetSize(aDest.Width, aDest.Height);   // Convert degrees to radians. Use minus sign to force clockwise rotation.   Radians   :=aAngle*PI/180;   RadiansSin:=sin(Radians);   RadiansCos:=cos(Radians);   // Step through each row of rotated image.   for y:=0 to aDest.Height-1 do   begin     yDest  :=y-aOffset.y;     yPrime :=2*(yDest-aAxis.y)+1; // center y: -1,0,+1     // Step through each col of rotated image.     for x:=0 to aDest.Width-1 do     begin       xDest :=x-aOffset.x;       xPrime:=2*(xDest-aAxis.x)+1; // center x: -1,0,+1       // Rotate (xPrime, yPrime) to location of desired pixel       // Note:  There is negligible difference between floating point and scaled integer arithmetic here, so keep the math simple (and readable).       xPrimeRotated:=round(xPrime*RadiansCos-yPrime*RadiansSin);       yPrimeRotated:=round(xPrime*RadiansSin+yPrime*RadiansCos);       // Transform back to pixel coordinates of image, including translation       // of origin from axis of rotation to origin of image.       xOriginal:=(xPrimeRotated-1) div 2+aAxis.x;       yOriginal:=(yPrimeRotated-1) div 2+aAxis.y;       // Make sure (xOriginal, yOriginal) is in aSource.  If not, assign blue color to corner points.       if (xOriginal>=0) and (xOriginal<=aSource.Width-1) and (yOriginal>=0) and (yOriginal<=aSource.Height-1) then       begin         // Assign pixel from rotated space to current pixel in aDest         RotateImg.Colors[x,y]:=NormalImg.Colors[xOriginal,yOriginal];       end       else if aSource.Height>0 then       begin         RotateImg.Colors[x,y]:=NormalImg.Colors[0,0];       end       else         RotateImg.Colors[x,y]:=TColorToFPColor(clBlack);     end;   end;   aDest.LoadFromIntfImage(RotateImg);   RotateImg.Destroy;   NormalImg.Destroy; end; After changes: Code: [Select]procedure RotateBitmap(aSource,aDest:Graphics.TBitmap; aAngle:double; aAxis,aOffset:TPoint); var   x            :integer;   xDest        :integer;   xOriginal    :integer;   xPrime       :integer;   xPrimeRotated:integer;   //   y            :integer;   yDest        :integer;   yOriginal    :integer;   yPrime       :integer;   yPrimeRotated:integer;   //   Radians      :double;   RadiansCos   :double;   RadiansSin   :double;   NormalImg    :TLazIntfImage;   RotateImg    :TLazIntfImage;   aDestHandle  : HBITMAP;   aDestMaskHandle: HBITMAP; begin   // create intermediary images   NormalImg := TLazIntfImage.Create(0, 0);   NormalImg.LoadFromBitmap(aSource.Handle, aSource.MaskHandle);   RotateImg := TLazIntfImage.Create(0, 0);   RotateImg.LoadFromBitmap(aDest.Handle, aDest.MaskHandle);   // Convert degrees to radians. Use minus sign to force clockwise rotation.   Radians   :=aAngle*PI/180;   RadiansSin:=sin(Radians);   RadiansCos:=cos(Radians);   // Step through each row of rotated image.   for y:=0 to aDest.Height-1 do   begin     yDest  :=y-aOffset.y;     yPrime :=2*(yDest-aAxis.y)+1; // center y: -1,0,+1     // Step through each col of rotated image.     for x:=0 to aDest.Width-1 do     begin       xDest :=x-aOffset.x;       xPrime:=2*(xDest-aAxis.x)+1; // center x: -1,0,+1       // Rotate (xPrime, yPrime) to location of desired pixel       // Note:  There is negligible difference between floating point and scaled integer arithmetic here, so keep the math simple (and readable).       xPrimeRotated:=round(xPrime*RadiansCos-yPrime*RadiansSin);       yPrimeRotated:=round(xPrime*RadiansSin+yPrime*RadiansCos);       // Transform back to pixel coordinates of image, including translation       // of origin from axis of rotation to origin of image.       xOriginal:=(xPrimeRotated-1) div 2+aAxis.x;       yOriginal:=(yPrimeRotated-1) div 2+aAxis.y;       // Make sure (xOriginal, yOriginal) is in aSource.  If not, assign blue color to corner points.       if (xOriginal>=0) and (xOriginal<=aSource.Width-1) and (yOriginal>=0) and (yOriginal<=aSource.Height-1) then       begin         // Assign pixel from rotated space to current pixel in aDest         RotateImg.Colors[x,y]:=NormalImg.Colors[xOriginal,yOriginal];       end       else if aSource.Height>0 then       begin         RotateImg.Colors[x,y]:=NormalImg.Colors[0,0];       end       else         RotateImg.Colors[x,y]:=TColorToFPColor(clBlack);     end;   end;   RotateImg.CreateBitmaps(aDestHandle, aDestMaskHandle);   aDest.Handle:=aDestHandle;   aDest.MaskHandle:=aDestMaskHandle;   RotateImg.Destroy;   NormalImg.Destroy; end; Tested for color depth: 15, 16, 24 and 32 bpp on Windows and Linux (Ubuntu 10.04). Best regards paweld ---------------------------------------------------------------------- neobrasil08 · 2010-09-05 23:18 Hello Paweld I am reply your changes on project. Very good! Regards.