msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Text as Image

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise
Author Message
Meelis Lilbok



Joined: 04 Oct 2007
Posts: 62

PostPosted: Wed Aug 30, 2006 5:35 pm    Post subject: Text as Image Reply with quote

Hi

Is it possible to save text as BMP or any other format with VB6?
Lets say i have string "Hello World" and i want to save it as BMP where BMP
width=textwidth aso.



Best regards;
Mex

Archived from group: microsoft>public>vb>controls
Back to top
View user's profile Send private message
Mike D Sutton



Joined: 04 Oct 2007
Posts: 1298

PostPosted: Wed Aug 30, 2006 4:13 pm    Post subject: Re: Text as Image Reply with quote

> Is it possible to save text as BMP or any other format with VB6?
> Lets say i have string "Hello World" and i want to save it as BMP where BMP width=textwidth aso.

Drop a picturebox on your form, then use this code:

'***
Const DemoString As String = "Hello, world!"
Const Padding As Long = 2

With Picture1
.AutoRedraw = True

' Scale the control accordingly
Call .Move(0, 0, _
(.Width - .ScaleX(.ScaleWidth, .ScaleMode, .Container.ScaleMode)) + _
.ScaleX(Padding * 2, vbPixels, .Container.ScaleMode) + _
.ScaleX(TextWidth(DemoString), .ScaleMode, .Container.ScaleMode), _
(.Height - .ScaleY(.ScaleHeight, .ScaleMode, .Container.ScaleMode)) + _
.ScaleY(Padding * 2, vbPixels, .Container.ScaleMode) + _
.ScaleY(TextHeight(DemoString), .ScaleMode, .Container.ScaleMode))

' Set the initial text offset
.CurrentX = .ScaleX(Padding, vbPixels, .ScaleMode)
.CurrentY = .ScaleY(Padding, vbPixels, .ScaleMode)

' Draw the string
Picture1.Print DemoString

' Save the picture to disk
Call SavePicture(.Image, "C:\TestPic.bmp")
.AutoRedraw = False
End With
'***

If you don't want to rely on having this additional control laying around (or you have no forms in your project) then
this can also be accomplished using the Win32 API too.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
Back to top
View user's profile Send private message
Meelis Lilbok



Joined: 04 Oct 2007
Posts: 62

PostPosted: Wed Aug 30, 2006 6:16 pm    Post subject: Re: Text as Image Reply with quote

allready figured out Wink


Thnx anyway.


Mex


"Meelis Lilbok" wrote in message %23$BzGHA.4392@TK2MSFTNGP04.phx.gbl...
> Hi
>
> Is it possible to save text as BMP or any other format with VB6?
> Lets say i have string "Hello World" and i want to save it as BMP where
> BMP width=textwidth aso.
>
>
>
> Best regards;
> Mex
>
Back to top
View user's profile Send private message
Meelis Lilbok



Joined: 04 Oct 2007
Posts: 62

PostPosted: Wed Aug 30, 2006 6:26 pm    Post subject: Re: Text as Image Reply with quote

I still need your help please Wink

because i need this functionality for my ASP project as ActiveX DLL, then i
need to use API.

any samples Mike?

or any other good idea for creating image in VB,ASP? Wink


Mex






"Mike D Sutton" wrote in message @TK2MSFTNGP04.phx.gbl...
>> Is it possible to save text as BMP or any other format with VB6?
>> Lets say i have string "Hello World" and i want to save it as BMP where
>> BMP width=textwidth aso.
>
> Drop a picturebox on your form, then use this code:
>
> '***
> Const DemoString As String = "Hello, world!"
> Const Padding As Long = 2
>
> With Picture1
> .AutoRedraw = True
>
> ' Scale the control accordingly
> Call .Move(0, 0, _
> (.Width - .ScaleX(.ScaleWidth, .ScaleMode, .Container.ScaleMode)) +
> _
> .ScaleX(Padding * 2, vbPixels, .Container.ScaleMode) + _
> .ScaleX(TextWidth(DemoString), .ScaleMode,
> .Container.ScaleMode), _
> (.Height - .ScaleY(.ScaleHeight, .ScaleMode, .Container.ScaleMode))
> + _
> .ScaleY(Padding * 2, vbPixels, .Container.ScaleMode) + _
> .ScaleY(TextHeight(DemoString), .ScaleMode,
> .Container.ScaleMode))
>
> ' Set the initial text offset
> .CurrentX = .ScaleX(Padding, vbPixels, .ScaleMode)
> .CurrentY = .ScaleY(Padding, vbPixels, .ScaleMode)
>
> ' Draw the string
> Picture1.Print DemoString
>
> ' Save the picture to disk
> Call SavePicture(.Image, "C:\TestPic.bmp")
> .AutoRedraw = False
> End With
> '***
>
> If you don't want to rely on having this additional control laying around
> (or you have no forms in your project) then this can also be accomplished
> using the Win32 API too.
> Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@mvps.org
> WWW: Http://EDais.mvps.org/
>
Back to top
View user's profile Send private message
Mike D Sutton



Joined: 04 Oct 2007
Posts: 1298

PostPosted: Wed Aug 30, 2006 4:30 pm    Post subject: Re: Text as Image Reply with quote

>I still need your help please Wink
>
> because i need this functionality for my ASP project as ActiveX DLL, then i need to use API.
>
> any samples Mike?
>
> or any other good idea for creating image in VB,ASP? Wink

Have a look at the following API calls:

CreateCompatibleDC()
CreateDIBSection()
CreateFont()
SelectObject()
GetTextExtentPoint32()
TextOut()
DeleteObject()
DeleteDC()

The DC, DDB and DIB articles on my site will help you with how to put it all together.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
Back to top
View user's profile Send private message
Thanh-Nhan Le



Joined: 04 Oct 2007
Posts: 3

PostPosted: Thu Aug 31, 2006 8:25 am    Post subject: Re: Text as Image Reply with quote

I think you can create a activex DLL, which had this function, then in ASP
code, you call this function (method).

I think, this is the simple way. Of course you need to install this DLL on
the webserver.

Nhan


"Meelis Lilbok" schrieb im Newsbeitrag @TK2MSFTNGP06.phx.gbl...
>I still need your help please Wink
>
> because i need this functionality for my ASP project as ActiveX DLL, then
> i need to use API.
>
> any samples Mike?
>
> or any other good idea for creating image in VB,ASP? Wink
>
>
> Mex
>
>
>
>
>
>
> "Mike D Sutton" wrote in message
> @TK2MSFTNGP04.phx.gbl...
>>> Is it possible to save text as BMP or any other format with VB6?
>>> Lets say i have string "Hello World" and i want to save it as BMP where
>>> BMP width=textwidth aso.
>>
>> Drop a picturebox on your form, then use this code:
>>
>> '***
>> Const DemoString As String = "Hello, world!"
>> Const Padding As Long = 2
>>
>> With Picture1
>> .AutoRedraw = True
>>
>> ' Scale the control accordingly
>> Call .Move(0, 0, _
>> (.Width - .ScaleX(.ScaleWidth, .ScaleMode, .Container.ScaleMode))
>> + _
>> .ScaleX(Padding * 2, vbPixels, .Container.ScaleMode) + _
>> .ScaleX(TextWidth(DemoString), .ScaleMode,
>> .Container.ScaleMode), _
>> (.Height - .ScaleY(.ScaleHeight, .ScaleMode,
>> .Container.ScaleMode)) + _
>> .ScaleY(Padding * 2, vbPixels, .Container.ScaleMode) + _
>> .ScaleY(TextHeight(DemoString), .ScaleMode,
>> .Container.ScaleMode))
>>
>> ' Set the initial text offset
>> .CurrentX = .ScaleX(Padding, vbPixels, .ScaleMode)
>> .CurrentY = .ScaleY(Padding, vbPixels, .ScaleMode)
>>
>> ' Draw the string
>> Picture1.Print DemoString
>>
>> ' Save the picture to disk
>> Call SavePicture(.Image, "C:\TestPic.bmp")
>> .AutoRedraw = False
>> End With
>> '***
>>
>> If you don't want to rely on having this additional control laying around
>> (or you have no forms in your project) then this can also be accomplished
>> using the Win32 API too.
>> Hope this helps,
>>
>> Mike
>>
>>
>> - Microsoft Visual Basic MVP -
>> E-Mail: EDais@mvps.org
>> WWW: Http://EDais.mvps.org/
>>
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Image List and Toolbar I have images in an image list, which provides the icons for my toolbar. But some images seem to have backgrounds, and others don't. e.g. some icons have a black square around them which I don't want. Is there a way of configuring the image list so that s

Image in a form as zoom How can set the image mode in a form, to zoom (not clip) as in Access ? (I have a big image and i want see all the image and not a small part of it)

Move+Image MI Thumbnail Support GIF, BMP, TIFF, PNG, ICON file format. Create ACDSee style image/movie Browser, only one minute. download vb sample from

listview back image Hi all I want to know how to make the image in a listview background get resized to fit the entire Listview area, when the listview get resized -- Thanks in advance Waleed Seada

Detect Ms-Word contains image (using VB 6) Hi, Can I detect if a MS-Word document contains images. (using VB 6) I plan to create an application that walks through all my Ms-Word documents and detects if they contain one or more images. After that i want to extract these images. Any suggestions. Sa
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise All times are GMT
Page 1 of 1

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


Powered by phpBB © 2001, 2005 phpBB Group