RTC Forums
November 24, 2024, 11:39:11 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Show Bitmap from ByteStream?  (Read 7007 times)
AndreFM
RTC Expired
*
Posts: 22


« on: October 01, 2011, 11:34:41 AM »

Hi Danijel,
At the iOS FishFact demo, I'm trying to display the image using the code below but is not working. I tried different ways, but it always shows nothing.
Code:
ImageControl1.Bitmap.LoadFromStream(Result.asByteStream['Graphic']);
Could you please let me know what I'm doing wrong?
Thank you
Regards
Andre
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: October 01, 2011, 08:35:28 PM »

The problem was that Graphic fields coming from Paradox tables contain a special TGraphicHeader before the actual image. My first solution was to update the iosTestClient Project to skip that special Header info before using "LoadFromStream" to fill the ImageControl, but I figured that some Databases Access components might NOT include that Header inside the Stream, which would make Client-side implementations dependant on Database Access components used on the Server, so I've decided to take a different approach.

Instead of skipping Graphic Header information on the Client, I've updated the "DelphiDataSetToRtc" function (used on the Server) to skip special Graphic Headers when preparing a RtcDataSet on the Server. This way, the Client will only receive the image inside the Stream, regardless of which Database Access components were used on the Server. In other words, if you download the latest RTC SDK version (v4.44) and recompile your Server, the following code will work with FireMonkey on iOS:
Code:
ImageControl1.Bitmap.LoadFromStream(Result.asDataSet.asByteStream['Graphic']);

PS. I've also extended the "iosTestClient" Project to display the "Graphic" field (using TImageControl), so there is now a ready-to-run example for using Graphic fields inside iOS Applications.

Best Regards,
Danijel Tkalcec
Logged
AndreFM
RTC Expired
*
Posts: 22


« Reply #2 on: October 01, 2011, 11:50:29 PM »

Thank you Danijel
Great work
Logged
AndreFM
RTC Expired
*
Posts: 22


« Reply #3 on: October 02, 2011, 12:37:47 AM »

Hi Danijel,
I updated my source in windows and mac, but when I compile in Xcode I get the error (see last lines):

Code:
Assembling (pipe) /Users/afm/Library/Developer/Xcode/DerivedData/iosTestClient-avesueqckevoqobkppgninlmvglt/Build/Products/Release-iphonesimulator/iosTestClient.app/rtcSocketHttpCliProv.s
Assembling (pipe) /Users/afm/Library/Developer/Xcode/DerivedData/iosTestClient-avesueqckevoqobkppgninlmvglt/Build/Products/Release-iphonesimulator/iosTestClient.app/rtcHttpCli.s
Compiling /Developer/Embarcadero/fmi/rtcDB.pas
rtcDB.pas(739,36) Error: identifier idents no member "GraphicHeader"
rtcDB.pas(795,34) Error: identifier idents no member "GraphicHeader"
rtcDB.pas(3167,4) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted

Regards
Andre
Logged
AndreFM
RTC Expired
*
Posts: 22


« Reply #4 on: October 02, 2011, 01:24:04 AM »

I commented the lines (rtcDB.pas)
Code:
   if //TBlobField(field).GraphicHeader and
because at the DB.pas in FPC from Embarcadero there is no property GraphicHeader. Not sure if this is the correct solution, but it's working.

But could you please let me know why it works with the BDEDemoServer and not with FishFactServer?
I was always using the FishFactServer and got no result, then I tried the BDE demo and now it works.
Logged
AndreFM
RTC Expired
*
Posts: 22


« Reply #5 on: October 02, 2011, 01:39:19 AM »

Just one suggestion for the iOS sample, I think it's better to use the following lines for the Prior and Next button.

Code:
procedure TForm2.btnNextClick(Sender: TObject);
  begin
  if assigned(MyDataSet) then
    begin
    MyDataSet.Next;
    if MyDataset.EOF then
      MyDataset.Prior;
    UpdateBitmap;
    end;
  end;

procedure TForm2.btnPriorClick(Sender: TObject);
  begin
  if assigned(MyDataSet) then
    begin
    MyDataSet.Prior;
    if MyDataset.EOF then
      MyDataset.Next;
    UpdateBitmap;
    end;
  end;
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: October 02, 2011, 02:33:50 AM »

Sorry. I forgot to try compiling the "rtcDB.pas" unit with FPC, because it isn't really needed by iOS Clients. You saw the error message because I also forgot to remove the "rtcDB" unit from "iosTestClient" Projects uses clause.

Anyway ... I've fixed the "rtcDB.pas" unit so it can also be compiled with FPC.
And ... I've updated the "iosTestClient" Project to use only required units.
Updated RTC SDK (v4.45) is now ready for download.

As for the FishFactServer Project, you need to use the "FishFacts.data" file included in the latest RTC SDK update, or recreate the file with the latest RTC SDK release by declaring the "RECREATE_TABLE" compiler directive in the "FishFactServer" Project, running the FishFactServer Project and closing it (this will create a new "FishFacts.data" file), then removing the compiler directive and building the FishFactServer Project again. After that, you will also be able to use the "FishFactServer" Project with the "iosTestClient" Project.

Best Regards,
Danijel Tkalcec
Logged
AndreFM
RTC Expired
*
Posts: 22


« Reply #7 on: October 02, 2011, 02:56:16 AM »

Thank you again for explanation and very quick answer :-)
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.027 seconds with 17 queries.