Author |
Topic  |
|
sandy771
 
57 Posts |
Posted - Nov 18 2014 : 14:49:07
|
Hi
I am trying to draw a marker on a slippymap and then save the map as a jpeg in a DB as a blob
My code is below - the elipse is drawn and display ed on the map but it is not written to the jpg that is saved to the blob - any ideas why?
Thanks
ies->Latitude = lat; ies->Longitude = lon; ies->PointPosition = Point(ImEn2->IEBitmap->Width / 2, ImEn2->IEBitmap->Height / 2);
ieh = ImEn2->AddNewObject(); ImEn2->ObjKind[ieh] = iekELLIPSE; ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix)); ImEn2->ObjPenColor[ieh] = clRed;
ies->Zoom = 14; ImEn2->Update(); ImEn2->LayersMergeAll(); Application->ProcessMessages(); picstrm = CaseQuery->CreateBlobStream((TBlobField*)CaseQuery->FieldByName("map1"), bmWrite); ImEn2->IO->SaveToStreamJpeg(picstrm);
|
|
xequte
    
39142 Posts |
Posted - Nov 18 2014 : 22:19:38
|
Hi
If you are saving to a JPEG then you will need to merge the objects into the background layer:
...
ImEn2->CopyObjectsToBack(true);
ImEn2->.RemoveAllObjects;
ImEn2->IO->SaveToStreamJpeg(picstrm);
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
sandy771
 
57 Posts |
Posted - Nov 19 2014 : 03:25:24
|
Thanks NIgel - that doesn't work for me :(
ImEn2 is a TImageEnVect
code is now
ImEn2->Update(); ieh = ImEn2->AddNewObject(); ImEn2->ObjKind[ieh] = iekELLIPSE; ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix)); ImEn2->ObjPenColor[ieh] = clRed; ImEn2->CopyObjectsToBack(true); ImEn2->RemoveAllObjects(); Application->ProcessMessages(); picstrm1 = CaseQuery->CreateBlobStream((TBlobField*)CaseQuery->FieldByName("map1"), bmWrite); ImEn2->IO->SaveToStreamJpeg(picstrm1);
I have tried different variants of the above. The elipse is correctly drawn but not saved to the DB. I have tried versions 4.3.0 and 5.0.5 with the same results (have requested 5.2.0) |
 |
|
sandy771
 
57 Posts |
Posted - Nov 19 2014 : 12:13:03
|
Now tried with 5.2.0 anyone help with this problem? It seems like it should be simple.
A few other posts have highlighted bugs with CopyObjectsToBack() is this one of them? |
 |
|
xequte
    
39142 Posts |
Posted - Nov 20 2014 : 12:16:42
|
Hi
First of all narrow down the problem, by replacing the Blob call with a simple mEn2->IO->SaveToFileJPEG(). Does the file contain the ellipse?
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
xequte
    
39142 Posts |
Posted - Nov 20 2014 : 14:02:48
|
Actually, I just tested:
ImEn2->Update();
ieh = ImEn2->AddNewObject();
ImEn2->ObjKind[ieh] = iekELLIPSE;
ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix));
ImEn2->ObjPenColor[ieh] = clRed;
ImEn2->CopyObjectsToBack(true);
ImEn2->RemoveAllObjects();
ImEn2->IO->SaveToFileJpeg("d:\\temp\\vector1.jpg");
And it worked fine.
So you are sayign that after RemoveAllObjects, ImEn2 (on-screen) does not show the burnt ellipse?
Are you sure you are using v5.2.0? There were some issues in v5.1.1 regarding the defaults for objects. Check ObjPenWidth = 1 and ObjPenStyle is psSolid.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
sandy771
 
57 Posts |
Posted - Nov 20 2014 : 17:13:44
|
Well this is weird then
Just run the following code and no elipse shown on screen or in the jpeg on disk
Comment out RenoveAllObject and the ellipse is shown on screen but NOT in the jpeg.
ImageEnVersion in the Object Inspector say 5.2.0
Just let me know what else I can do to help get to the bottom of this.
Cheers Paul
class TForm2 : public TForm { __published: // IDE-managed Components TImageEnVect *ImEn2; TButton *Button1; void __fastcall FormShow(TObject *Sender); void __fastcall Button1Click(TObject *Sender); private: // User declarations
TIESlippyMap *ies;
public: // User declarations __fastcall TForm2(TComponent* Owner); };
void __fastcall TForm2::FormShow(TObject *Sender) { ies = new TIESlippyMap(iesmpMapQuest, "e:\\temp\\mapcache"); ImEn2->IEBitmap->VirtualBitmapProvider = ies; } //--------------------------------------------------------------------------- void __fastcall TForm2::Button1Click(TObject *Sender) { int x1 = ImEn2->IEBitmap->Width /2; int y1 = ImEn2->IEBitmap->Height / 2; int pix = 10;
ImEn2->Update(); int ieh = ImEn2->AddNewObject(); ImEn2->ObjKind[ieh] = iekELLIPSE; ImEn2->ObjPenWidth[ieh] = 1; ImEn2->ObjPenStyle[ieh] = psSolid; ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix)); ImEn2->ObjPenColor[ieh] = clRed; ImEn2->CopyObjectsToBack(true); ImEn2->RemoveAllObjects(); ImEn2->IO->SaveToFileJpeg("e:\\temp\\vector1.jpg");
} |
 |
|
xequte
    
39142 Posts |
Posted - Nov 20 2014 : 17:26:29
|
Hi
That would indicate that "CopyObjectsToBack" is failing.
Create a new blank project with a TImageEnVect and two buttons. One to load an image and the other with:
int ieh = ImEn2->AddNewObject();
ImEn2->ObjKind[ieh] = iekELLIPSE;
ImEn2->ObjPenWidth[ieh] = 1;
ImEn2->ObjPenStyle[ieh] = psSolid;
ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix));
ImEn2->ObjPenColor[ieh] = clRed;
ImEn2->CopyObjectsToBack(true);
ImEn2->RemoveAllObjects();
ImEn2->IO->SaveToFileJpeg("e:\\temp\\vector1.jpg");
Does even that fail?
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
sandy771
 
57 Posts |
Posted - Nov 20 2014 : 17:43:35
|
That works - the saved jpg has the ellipse.
void __fastcall TForm2::Button1Click(TObject *Sender) { ImEn2->IO->LoadFromFileJpeg("e:\\temp\\vector.jpg"); } //--------------------------------------------------------------------------- void __fastcall TForm2::Button2Click(TObject *Sender) { int x1 = ImEn2->IEBitmap->Width /2; int y1 = ImEn2->IEBitmap->Height / 2; int pix = 10; int ieh = ImEn2->AddNewObject(); ImEn2->ObjKind[ieh] = iekELLIPSE; ImEn2->ObjPenWidth[ieh] = 1; ImEn2->ObjPenStyle[ieh] = psSolid; ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix)); ImEn2->ObjPenColor[ieh] = clRed; ImEn2->CopyObjectsToBack(true); ImEn2->RemoveAllObjects(); ImEn2->IO->SaveToFileJpeg("e:\\temp\\vector1.jpg"); } |
 |
|
xequte
    
39142 Posts |
Posted - Nov 20 2014 : 17:56:10
|
OK. Now select the TImageEnVect in your demo and click Ctrl+C and paste it to a Notepad. Do the same with the TImageEnVect in the test project.
Is there any difference in the properties?
If that does not reveal anything, then comment out any code in your project that might affect the TImageEnVect and see if that makes it work. If it does, add back the code line-by-line until you find the culprit.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
sandy771
 
57 Posts |
Posted - Nov 21 2014 : 02:06:07
|
Morning Bill
Thanks for the update - sorry timezone issues menat I have only just got to look at this
I am just popping out and before I have had chance to look properly I wanted to show you the following
I used the same demo program and just changed the content of the button1 code to load a slippy map (so the ImageEnVect properties have not changed).
I replaced the Loadfromjpeg with the code below, and moved Update so the map was displayed when the first button clicked. With this small change to the code no ellipse is drawn in ImageEnVect and subsequently nothing written to the jpeg
Just let me know what else I can do please.
Cheers
void __fastcall TForm2::Button1Click(TObject *Sender) { // ImEn2->IO->LoadFromFileJpeg("e:\\temp\\vector.jpg"); ies = new TIESlippyMap(iesmpMapQuest, "e:\\temp\\mapcache"); ImEn2->IEBitmap->VirtualBitmapProvider = ies; ImEn2->Update(); } //--------------------------------------------------------------------------- void __fastcall TForm2::Button2Click(TObject *Sender) { // ImEn2->Update(); int x1 = ImEn2->IEBitmap->Width /2; int y1 = ImEn2->IEBitmap->Height / 2; int pix = 10; int ieh = ImEn2->AddNewObject(); ImEn2->ObjKind[ieh] = iekELLIPSE; ImEn2->ObjPenWidth[ieh] = 1; ImEn2->ObjPenStyle[ieh] = psSolid; ImEn2->SetObjRect (ieh, Rect(x1-pix,y1-pix,x1+pix,y1+pix)); ImEn2->ObjPenColor[ieh] = clRed; ImEn2->CopyObjectsToBack(true); ImEn2->RemoveAllObjects(); ImEn2->IO->SaveToFileJpeg("e:\\temp\\vector1.jpg"); |
 |
|
xequte
    
39142 Posts |
Posted - Nov 24 2014 : 19:28:55
|
Sorry, I was so focused on the IEVect code that I missed the obvious. The IEVect display bitmap is a VirtualBitmapProvider, so you cannot use CopyObjectsToBack, because the "back" is only virtual.
What you need to do is assign the IEBitmap containing the TIESlippyMap to a TImageEnVect.IEBitmap, then use your code (on that IEVect) to add an ellipse and merge it.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
sandy771
 
57 Posts |
Posted - Nov 25 2014 : 03:50:57
|
Thanks Nigel - that did the trick. |
 |
|
|
Topic  |
|