Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

3 Neutral
  1. bobD

    memory usage of TJPGImage

    That encourages me that I'm on the right track with bitmaps. I'll report back with some further testing.
  2. bobD

    memory usage of TJPGImage

    In what regard? What I know so far is this: the lines img.Scale := jsEighth; img.Performance := jpBestSpeed; speed up the load/display of the jpg file as advertised Using the following code, bmp := TBitMap.Create(img.Width, img.Height); bmp.Assign(img); bmp.SaveToFile('C:\Users\bobd\Desktop\TestBMP.bmp'); and starting with a jpg file of 15.4 MB results in a bmp file of about 1.14 MB if Scale and Performance are so specified, or with the lines commented out 73MB (!). That suggests to me that there's no direct calculation of the JPGImage size from the bitmap it produces. You can see either a > 10x reduction, or a 4-5x expansion. Interestingly though, the TJPGImage object saving itself to file after the scale and performance are reduced for load results in a file the same size as the original. So we can't assume that the TJPGImage so loaded is any smaller in memory that one loaded without the jsEighth reduction. That's interesting. It appears to me that the most memory efficient cache (and thus the one with the largest practical capacity) for this app is going to be loading at jsEighth, then creating and caching the bitmap. Since the original image can be 6192 x 4192, I don't really need all that resolution anyway. Unfortunately, this presumes something not in evidence: that the size of the TBitmap in memory has a direct relationship to its file size. As with the source TJPGImage, it doesn't have an accessible size-in-memory property.
  3. bobD

    memory usage of TJPGImage

    I can do that. Is that suggested for performance or memory footprint? It bugs me that I can't see what I'm doing. InstanceSize returns 100 bytes for the img, 24 bytes for the stream. Obviously neither really accounts for the data. bobD
  4. bobD

    memory usage of TJPGImage

    I'm working on a quick photo browsing app, using a TObjectDictionary<string, TJPEGImage> as a cache device. Images are requested for display using the path to the jpg file like this: procedure TJpgStore.LoadPicture(aPicture: TPicture; const aSource: string); var img : TJPEGImage; begin if not FDict.TryGetValue(aSource, img) then begin img := TJPEGImage.Create; img.Scale := jsEighth; img.Performance := jpBestSpeed; img.LoadFromFile(aSource); FDict.Add(aSource, img); end; aPicture.Assign(img); end; This all seems to work fine, but two questions (since I'm not really a graphics guy): Am using Scale and Performance correctly? IOW, does it make any difference being here or after the LoadFromFile call? How much memory does a loaded TJPGImage take up? ('m thinking about a least-recently-used cache size governor. The jpgs are commonly 15-25MB each, and a source directory might contain 1-5,000 picture, so caching them all doesn't seem realistic...) Those are specific questions, but glad to entertain other comments/suggestions/alternative approaches. Thanks, bobD
  5. For whatever reason I've never used cached updates. Fuller context is that I have an app on my local home network that uses an IB server. There are two main failure conditions: (1) the laptop's Wifi connection to the server is wonky, or (2) I'm off traveling and not on the home network at all. I'm currently considering three different architectural approaches as I go from simple C/S design to briefcase (or more generally a 'network-optional' design). 1. Use IB's built-in change views--this would be preferred if I could find a decent tutorial for getting started. Major documentation shortfall here. 2. Use a server first approach (app tries to connect to IB server, failing that it opens local IB database). Obviously that requires I write a server<-->local reconciliation routine. 3. Use a local-first approach. That removes the need for solving the network slow-fail issue, because all server communication would be confined to the background reconciliation thread.
  6. Thanks for suggestion. I've actually isolated the problem at this point to the WiFi connection being flaky, since the app works fine on the wired-in network machines even as the laptop fails to connect, and stopping/starting the laptop wifi service always fixes the problem. The DB machine and DB are solid as a rock. One of the things I'm thinking about doing as the app evolves is making it briefcase-enabled by running an local DB, and having the app run locally if the server isn't available. That creates an obvious synchronization requirement of course, and hence my interest in learning about change views. But that might be way more complicated than I actually need--the data at this point is pretty stable.
  7. I'll probably go with that for the moment. And I'll admit that 'seeming forever' is a very subjective complaint. The app normally opens with a fully populated dataset w/i a second or 2, so waiting is just waiting for inevitable exception handler. bobD
  8. Thanks Fr0st-- See my reply to Anders--Given the type of connection fails I get, I'm not actually looking for a 100% solution. Unreliable might be fine depending on why the test fails. For example, I wonder whether I can ask the router if the sever is available rather than even trying to even talk to it. The server itself doesn't publish for network browsing, nor does it even respond to pings--effectively it's stealth except for the database connection (on the standard 3050 port).
  9. Thanks Anders-- Home network, so the connection itself is 99.9+% reliable. The only time it can change is if I do it. What normally happens is that the laptop for whatever reason loses its wifi connection to the server. Turning wifi off and on always fixes things. And I simply don't see any failures on the wired-in desktops. So I'm perfectly fine with a file check not actually testing the connection validity, just whether the server is reachable.
  10. Environment is current Delphi 10.4.2 FIreDac working against up-to-date 2021 Interbase What's the best tutorial or book for developing a Delphi-Interbase change-view based app? Looking for some simple procedure tips like a. develop for server first, then add local when design stable? b. develop for local first, then add network database when design stable? c develop using change views from the start? Also, does using change-views carry any db design implications? My normal practice in C/S development has been using a key-cache or Hi/Lo approach with integer keys (https://en.wikipedia.org/wiki/Hi/Lo_algorithm), but wondering if I need to switch to GUIDS... Thanks for any help/tips/references bobD
  11. Environment is current Delphi 10.4.2 FIreDac working against up-to-date network IB server. I have an app that opens the database on startup. However, while calling Connected := True is fine if it works, it can take seeming-forever to fail if the server can't be reached. Is there a faster call in FD/IB to make sure that a network server can be reached? My standing practice has been to call FileExists(<db or marker file>) as a simple precheck on a connection, but that doesn't work in this case because the server does not publish its existence. FB can connect, but the server doesn't show up in standard network browsing. So if you type in a server location in FileExplorer it will request connection credentials, but FileExists simply fails. I haven't found an access-credentialed version of DirectoryExists or FileExists that I can use. Thanks for any help/pointers, bobD
  12. Certainly. but the details of that would depend entirely on the database schema, including knowledge of the table structures, the view you're referring to, and any/all other relevant complications (such as db triggers and rights of the the user connection.) One of the first questions that occurs to me is "what do you mean by an 'invoice'? My tendency is to regard invoices as simply statements (ie, point-in-time reports) of the financial status of an account. The 'real' underlying objects being reported on are the account and its billable orders. Credits applied to an account would normally be applied to each billable order amount in sequence from oldest to newest until the credit was exhausted, w/ any amount left over then becoming a positive balance (credit) on the account. A superseding invoice or refund might then be generated to reflect the new account status. bobD
  13. bobD

    getting started question: ToGo or Local

    Don't know if I provided too much context or not enough. I've got a pretty good idea what's slowing down the wifi, but not really interested in that, because (1) the unit router actually belongs to the apartment building. It's single band 2.4, but more than adequate for most purposes, and more importantly (2) this is mostly just an excuse to learn more about IB and FireDAC. I worked professionally against SQLServer for well over a decade, mostly dbGo, but also ODBC and (many years ago} BDE. But I never had the occasion to write a briefcase app: all strictly C/S. Since I'm retired now I have time to learn IB and FireDAC. What I didn't see in the Rad Studio samples is a pair of clear examples of the difference between setting up a Delphi FireDAC app to run IB embedded vs IB desktop. Is that a matter of FireDAC connection settings? Specific files in the connection datamodule uses clause? Some specific FD physical layer support component? I can easily set up a local IB connection, but since my dev machines have a local IB server running, I can't say for sure I know whether it's embedded vs desktop. I want to get the connection options completely sussed before moving into all the other new (to me) IB/FD goodies bobD
  14. bobD

    Database app good practice

    From the description of where you are ("click on button perform queries and display results"), this is an immense topic. Probably the classic intro to object oriented design is Object-Oriented Software Construction by Bertrand Meyer For a simpler approach (and with the benefit of being written for Delphi), try NIck Hodges' books on coding in Delphi. They're straightforward and very approachable. Bit more detail in Hands-On Design Patterns with Delphi by Primoz Gabrijelcic These will get you started with OO thinking--the prerequisite to architectural layering. In the mean time, how to refactor your current code to make it more maintainable? I'd suggest trying this: New rule: no data access objects on forms. Those belong in data modules. Organize the modules into groups of logically related queries. That will start to separate out your code by 'topic of concern' so you can start grouping logically related code. bobD
  15. Context latest Delphi 10.4.1, Arch and Interbase 2020. Windows 10. FireDac. Local home network, both cat-6 wired (desktops) and wifi (laptops) The laptops are much slower on connecting--enough to be annoying--so I'm thinking about using primarily either ToGo or a local IB server. The data has a high-use but low volatility, so coordinating between the local and main servers will be relatively trivial. Is there a good sample app for setting up an embedded or local IB delphi app? I assume I have to include different files. The one briefcase model I found used a server and local flat files. Thanks for any help or links. bobD