Jump to content


uniGUI Subscriber
  • Posts

  • Joined

  • Last visited

  • Days Won


Kattes last won the day on July 7 2021

Kattes had the most liked content!

Recent Profile Visitors

1177 profile views

Kattes's Achievements

Active Member

Active Member (3/4)



  1. Hi again, Please forget my question above - I finally found out that not uniGUI is responsible for the issue with Safari mobile. The problem comes from an Iframe I used to wrap the uniGUI application into an external HTML page. To get my problem fixed I just added the following to the HTML-code of my wrapper: <script> window.addEventListener('touchstart', {}); </script> So if anyone comes across the same problem with iframes, this is the solution. Best regards, Kattes
  2. Hi there, Just a very simple question: Is it possible to use mouse events (OnMouseDown, OnMouseClick, OnMouseUp) in a standard uniGUI application if running it on an iPhone Safari browser? It seems so that none of these events are working if this browser is used. No problems with Chrome and Android, but Safari mobile seems to be somehow "special". Kind regards, Kattes
  3. Thank you Sherzod. As always I appreciate your help!
  4. Yes, this is exactly what I mean. The program assigns two different UnimImages the same content only with a different size - but you will get two different pattern. If you scan the sharper QR-Code it will show you something which was build in the past from a totally different session, which also could be closed already. So it really looks like a memory crosstalk problem.
  5. Can you try my exe, please?
  6. Have you tried my compiled exe or did you build a new one?
  7. I had a similar idea, but to work with a MemoryStream instead of a file. Unfortunately, all these tests are very time-consuming and at the end I still don't know if the problem has really been solved or if I just didn't do enough tests to find the error.
  8. Hi guys, I really appreciate your help and support. It shows me again how important it is to have an active community of people willing to help. Ultimately though, the QR code library is not the problem here. The problem comes from the UnimImage component, which is exhibiting this strange behavior. So I'm pretty sure that this effect also can occurs if you assign a different bitmap source to UnimImage. Of course, the effect is not so dramatic if it shows a puppy instead of a cat 🙂 .
  9. Sorry if I didn't make it clear. I will try to describe the effect again based on the testcase I created. If you open the source code you will see that there is only one method, which is responsible to create a string, which then will be used to create a QR-Code bitmap using an external library. The content of the String is also assigned to a Label to make it visible. First part of the string is constant during a session and the last part varies with every mouse click on the refresh label. The generated QR-Code bitmap will be assigned to two different unimImages. The first Image get the content of the QR-Code bitmap directly via : UnimImage1.Picture.Bitmap.Assign(QRCodeBitmap); The second UnimImage gets the content of the same QR-Code Bitmap via StretchDraw: w := QRCodeBitmap.Width * 8; h := QRCodeBitmap.Height * 8; UnimImageQR.Picture.Bitmap.Width := w; UnimImageQR.Picture.Bitmap.Height := h; UnimImageQR.Picture.Bitmap.Canvas.StretchDraw(Rect(0,0,w,h), QRCodeBitmap); So everybody now would think that next to the zoom level both images will look equal, but for whatever reason this is sometimes NOT the case. If this happens the content of UnimImageQR is not something totally stupid, because if you scan the code with a QR-Scanner App its content string is something which was created before from a totally different session. So all this is totally unlogic and crazy, but it happens! For whatever reason the zoom factor also plays a role here. A higher value than 8 seems to minimize the risk of this effect - don't ask me why. As some kind of a hotfix I am now using a zoom factor of 80 and only can pray that if the next event comes up it will not end in chaos again, with hundreds of visitors with doubled QR-Codes.
  10. Attached you will find the simplified test-case. I have thrown out everything what is not needed. For testing the behavior you will need two running instances of the web-application. Best is to run it in two different Browser Windows. Click Refresh and a new QR-Code will generated. The sharp one is zoomed by factor 8. Once you have clicked refresh some times in the first browser window switch to the second one and click refresh here as long as you cannot see a difference in the QR-pattern. Sometimes it will take a while but I am pretty sure that you will see the effect, too. TestCase.zip
  11. if a deviation is happening, it will happen in both parts of the string so sUserId AND sTransferRef. This is so crazy, so I think I will make a test case for everybody, who is interesting in this case. Further news from my tests: If I increase the bitmap zoom factor from 8 to e.g. 80 the effect seams to go away !
  12. UserId is the record ID of the new created user record coming from the database and sTransferRef is randomly created 6 character string (as you can see from my last post - here the variable is called "s"). But the problem is coming from UnimImage component. It seems to load content coming from somewhere sometimes ?!?!?
  13. Some more from my research... procedure TuFrameDetails.UnimPanelSellMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var i,w,h : integer; s : string; QRCodeBitmap : tBitmap; begin Randomize; s := '123456'; for i := 1 to length(s) do s[i] := Chr(Ord('A')+ Random(26)); with UniMainModule do begin sQR := sUserId + '-999999-'+ s; UnimLabelRef.Caption := sQR; QRCodeBitmap := CreateQRCode(sQR); try UnimImage1.Picture.Bitmap.Assign(QRCodeBitmap); // fits to string sQR from content 100% - but too small, so needs to be scaled to avoid antializing w := QRCodeBitmap.Width * 8; h := QRCodeBitmap.Height * 8; UnimImageQR.Picture.Bitmap.Width := w; UnimImageQR.Picture.Bitmap.Height := h; UnimImageQR.Picture.Bitmap.Canvas.StretchDraw(Rect(0,0,w,h), QRCodeBitmap); // looks sharp, but content is not always in line with string sQR finally QRCodeBitmap.Free; end; end; end; So the problem happens if I try to use Strechdraw to the UnimImage bitmap. Also assigning a stretched bitmap does not work reliable. So in summary the content of UnumImage1 and UnimImageQR is sometimes (next to their size, which is obvious) different. In such a case UnimImageQR shows something what happend in the past. I am using only one active browser window.
  14. Attached you will find the QRCode unit used and below, how it is used. procedure TuFrameDetails.UnimFormCreate(Sender: TObject); var QRCodeBitmap : tBitmap; sQR : string; begin with UniMainModule do begin bSkip := true; sQR := sUserId + '-999999-'+ sTransRef; UnimLabelRef.Caption := sQR; try QRCodeBitmap := CreateQRCode(sQR); ResizeBitmap(QRCodeBitmap,8); UnimImageQR.Picture.Bitmap.Assign(QRCodeBitmap); QRCodeBitmap.Free; finally bSkip := false; end; end; end; function TuFrameDetails.CreateQRCode(qrTxt: string): tBitmap; var QRCode: TDelphiZXingQRCode; Row, Column: Integer; begin QRCode := TDelphiZXingQRCode.Create; result := tBitmap.Create; try QRCode.Data := qrTxt; QRCode.Encoding := qrAuto; QRCode.QuietZone := 4; result.SetSize(QRCode.Rows, QRCode.Columns); for Row := 0 to QRCode.Rows - 1 do begin for Column := 0 to QRCode.Columns - 1 do begin if (QRCode.IsBlack[Row, Column]) then begin result.Canvas.Pixels[Column, Row] := rgb(0,0,32); end else begin result.Canvas.Pixels[Column, Row] := clWhite; end; end; end; finally QRCode.Free; end; end; procedure TuFrameDetails.ResizeBitmap(var Bmp: tBitmap; Scale: double); var BmpTemp: tBitmap; begin BmpTemp := TBitmap.create; BmpTemp.PixelFormat := Bmp.PixelFormat; BmpTemp.Width := trunc(Bmp.Width * Scale); BmpTemp.Height := trunc(Bmp.Height * Scale); BmpTemp.Canvas.StretchDraw(Rect(0,0,BmpTemp.Width, BmpTemp.Height), Bmp); Bmp.Free; Bmp := BmpTemp; end; QRCode.zip
  15. First of all, I would like to apologize for the somewhat lurid headline, but what happened to me yesterday made me doubt my more than 35 years of experience as a programmer. But first things first, what happened? I was programming a registration application for a local event organizer for his guests. Basically a very simple application that collects people's personal information, writes it into a database and then generates a QR code to be displayed on the mobile device and later scanned upon entry. To make sure that the code used for registration is unique, a 6-digit alpha string is generated and checked again with the database for uniqueness. All this works without any problems. The generated string is also displayed correctly on the mobile devices, but then something completely crazy happens when the string is converted into a QR code. Because here it sometimes happens that the content of the QR code does not match the displayed string content. But it is not the case that some nonsense is then generated, it is a QR code with the identical content from another session! It is simply not clear to me how this can happen. No global variables / or object instances are used and the code for generating the QR code also looks completely inconspicuous. I would be very grateful for any ideas and suggestions, because you can imagine what happens when two people with identical QR codes suddenly appear at the entrance....
  • Create New...