Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, May 10, 2005 8:36:42 AM(UTC)

fcandia  
fcandia

Groups: Registered
Posts: 5


I have been trying to draw text into a bitmap using vector sdk v13. This is a console project. I'm missing something, can anyone shed some light? I was able to get some samples from the docs working where I load in a vector file and render it to a bitmap, but my attempts to create my own VectorText object and render it are not working. I'm sure its something simple.

Thank you

 

 RECT rect;
 rect.top = rect.left = 0;
 rect.right = rect.bottom = 400;

 LVectorBase Vector;
 Vector.SetViewport(&rect);

 

 VECTORTEXT     Text;
 LVectorText VectorText;

 VectorText.LockObject(&Text);

 Text.Point.x = 50;
 Text.Point.y = 50;
 Text.Point.z = 0;

 Text.pszText = "LEAD Test";
 Text.Pen.LogPen.lopnColor = RGB(255,255,0);
 Text.Brush.LogBrush.lbColor = RGB(0,255,0);
 Text.CharHeight = 8;
 Text.CharWidth = 1;

 VectorText.UnlockObject(&Text);

 Vector.AddObject(&VectorText);

 //Vector.Load("sample.dxf");
 //Vector.AttachToWindow(hWnd);
 //GetClientRect(hWnd, &rect);

 LBitmapBase BitmapBase(400,400,24);
 Vector.Realize(BitmapBase,TRUE); 
 BitmapBase.Save("vector_test.bmp", FILE_BMP, 24, 2);

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, May 13, 2005 9:43:59 AM(UTC)

Ike  
Ike

Groups: Tech Support
Posts: 23

Thanks: 3 times

Are you getting errors, or it just doesn't produce the output you expect?
Make sure you are unlocking VECTOR support, and check your function calls for error returns.

Edited by moderator Thursday, March 30, 2017 12:08:27 PM(UTC)  | Reason: Not specified

Ike
LEAD Technologies, Inc.

LEAD Logo
 
#3 Posted : Monday, May 16, 2005 2:44:28 PM(UTC)

fcandia  
fcandia

Groups: Registered
Posts: 5


Hi, I added error checking and found that I needed to insert a layer first. The code builds and runs without error now but I get a blank bitmap. Any suggestions?

Thank you

Here is new code:

 int iRet;
 RECT rect;
 rect.top = rect.left = 0;
 rect.right = rect.bottom = 400;

 if( LSettings::IsSupportLocked(L_SUPPORT_VECTOR) )
  cout << "Vector support is locked!!\n";


 LVectorBase Vector;
 Vector.SetViewport(&rect);

 LVectorLayer layer;

 // add layer
 iRet = Vector.AddLayer(&layer);
 if( iRet != 1 )
  printf("Error adding layer error[%i]\n", iRet);

 iRet = Vector.SetActiveLayer(&layer);
 if( iRet != 1 )
  printf("Error setting active layer error[%i]\n", iRet);


 VECTORTEXT     Text;
 LVectorText VectorText;

 Text.Point.x = 50;
 Text.Point.y = 50;
 Text.Point.z = 0;

 Text.pszText = "LEAD Test";
 Text.Pen.LogPen.lopnColor = RGB(255,255,0);
 Text.Brush.LogBrush.lbColor = RGB(0,255,0);
 Text.CharHeight = 8;
 Text.CharWidth = 0;

 // add text object
 iRet = layer.AddObject(&VectorText);
 if( iRet != 1 )
  printf("Error adding object error[%i]\n", iRet);

 // render to bitmap
 LBitmapBase BitmapBase(400,400,24);
 iRet = Vector.Realize(BitmapBase,TRUE); 
 if( iRet != 1 )
  printf("Error realizing object error[%i]\n", iRet);

 iRet = BitmapBase.Save("vector_test.bmp", FILE_BMP, 24, 2);
 if( iRet != 1 )
  printf("Error saving bitmap error[%i]\n", iRet);

 
#4 Posted : Wednesday, May 25, 2005 1:41:16 PM(UTC)

support  
support

Groups: Registered, Tech Support
Posts: 20


I changed the code to get it working. Here's the modified version:
LBase::LoadLibraries(LV_KRN);
int iRet;
RECT rect;
rect.top = rect.left = 0;
rect.right = rect.bottom = 400;

if( LSettings::IsSupportLocked(L_SUPPORT_VECTOR) )
   printf("Vector support is locked!!\n");

LVectorBase Vector;
Vector.SetViewport(&rect);

VECTORPOINT point1={0,0,0,0}, point2={400,400,0,0};
Vector.SetParallelogram(&point1, &point2);


VECTORLAYERDESC VectorLayerDesc={0};
VectorLayerDesc.nSize = sizeof(VECTORLAYERDESC);
lstrcpy(VectorLayerDesc.szName, TEXT("First Layer"));
VectorLayerDesc.bVisible = TRUE;
VectorLayerDesc.bLocked = FALSE;
VectorLayerDesc.dwTag = 0;

LVectorLayer layer(&VectorLayerDesc);
// add layer
iRet = Vector.AddLayer(&layer);
if( iRet != 1 )
   printf("Error adding layer error[%i]\n", iRet);

iRet = Vector.SetActiveLayer(&layer);
if( iRet != 1 )
   printf("Error setting active layer error[%i]\n", iRet);


VECTORTEXT     Text = {0};
// VectorText.LockObject(&Text);
Text.Point.x = 50;
Text.Point.y = 50;
Text.Point.z = 0;

Text.pszText = "LEAD Test";
Text.Pen.LogPen.lopnColor = RGB(255,255,0);
Text.Brush.LogBrush.lbColor = RGB(0,255,0);
Text.CharHeight = 8;
Text.CharWidth = 0;
LVectorText VectorText(&Text);
// add text object
iRet = layer.AddObject(&VectorText);
if( iRet != 1 )
   printf("Error adding object error[%i]\n", iRet);
// render to bitmap
LBitmapBase BitmapBase(400,400,24);
iRet = Vector.Realize(BitmapBase,TRUE);
if( iRet != 1 )
   printf("Error realizing object error[%i]\n", iRet);
iRet = BitmapBase.Save("vector_test.bmp", FILE_BMP, 24, 2);
if( iRet != 1 )
   printf("Error saving bitmap error[%i]\n", iRet);

Amin Dodin
LEADTOOLS Technical Support

 
#5 Posted : Thursday, May 26, 2005 7:42:47 AM(UTC)

fcandia  
fcandia

Groups: Registered
Posts: 5


That works. How to I position the text? I Tried changing the Text x,y location as well as the dwFlag for alignment but it's not working.

Thanks

 
#6 Posted : Sunday, May 29, 2005 5:31:31 AM(UTC)

support  
support

Groups: Registered, Tech Support
Posts: 20


Keep in mind that the center point of the resulting BMP corresponds to coordinates (0,0) in the vector drawing. For example, to place the text in the left-top corner of the BMP file, set:
Text.Point.x = -200;
Text.Point.y = 200;

Amin Dodin
LEADTOOLS Technical Support

 

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.104 seconds.