473,395 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create an Image

Hi all
Here is my problem

I want to create an image so i can pass it on an object to put it as
watermark in my pdf report

Here is what i have write so far

Dim objBitmap As System.Drawing.Bitmap

Dim objGraphics As System.Drawing.Graphics

Dim cstream As System.IO.MemoryStream

Dim c As System.Drawing.Image

objBitmap = New System.Drawing.Bitmap(width, height)

objGraphics = System.Drawing.Graphics.FromImage(objBitmap)

Dim drawFont As New System.Drawing.Font("Arial", 32)

Dim drawBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Bla ck)

' Create point for upper-left corner of drawing.

Dim x As Single = 0.0F

Dim y As Single = 0.0F

' Set format of string.

Dim drawFormat As New System.Drawing.StringFormat

drawFormat.FormatFlags = System.Drawing.StringFormatFlags.DirectionVertical

g.DrawString("IMAGE TEXT", drawFont, drawBrush, x, y, drawFormat)

objBitmap.save ("c:\temp\a.jpg")

objBitmap.Save(cstream, System.Drawing.Imaging.ImageFormat.Jpeg)

c = System.Drawing.Image.FromStream(cstream)

c.Save("c:\temp\b.jpg")

Now if you look at the a.jpg and b.jpg the a.jpg contains an image that
writes the "IMAGE TEXT"

but b.jpg is totaly BLACK!!!!!

What i'm doing wrong??

Thank you for your time


Nov 21 '05 #1
2 1625
Hi,

Think you are draw the string off the visible area of the bitmap.
This should work.
Dim bm As New Bitmap(50, 50)

Dim g As Graphics = Graphics.FromImage(bm)

g.Clear(Color.Black)

g.TranslateTransform(25, 25)

g.RotateTransform(90)

g.DrawString("Hi", Me.Font, Brushes.White, 0, 0)

Ken

--------------------------

"Programmer" <se*******@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Hi all
Here is my problem

I want to create an image so i can pass it on an object to put it as
watermark in my pdf report

Here is what i have write so far

Dim objBitmap As System.Drawing.Bitmap

Dim objGraphics As System.Drawing.Graphics

Dim cstream As System.IO.MemoryStream

Dim c As System.Drawing.Image

objBitmap = New System.Drawing.Bitmap(width, height)

objGraphics = System.Drawing.Graphics.FromImage(objBitmap)

Dim drawFont As New System.Drawing.Font("Arial", 32)

Dim drawBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Bla ck)

' Create point for upper-left corner of drawing.

Dim x As Single = 0.0F

Dim y As Single = 0.0F

' Set format of string.

Dim drawFormat As New System.Drawing.StringFormat

drawFormat.FormatFlags = System.Drawing.StringFormatFlags.DirectionVertical

g.DrawString("IMAGE TEXT", drawFont, drawBrush, x, y, drawFormat)

objBitmap.save ("c:\temp\a.jpg")

objBitmap.Save(cstream, System.Drawing.Imaging.ImageFormat.Jpeg)

c = System.Drawing.Image.FromStream(cstream)

c.Save("c:\temp\b.jpg")

Now if you look at the a.jpg and b.jpg the a.jpg contains an image that
writes the "IMAGE TEXT"

but b.jpg is totaly BLACK!!!!!

What i'm doing wrong??

Thank you for your time



Nov 21 '05 #2
No that's not it
If you run the code the image is draw in a visible area.
That's the reason Save both files phisicaly to see if it's ok
The Bitmap is created succesfully and it also saved succesfully.

But then i try to pass it on an image object the image.save is black.

If i save the bitmap in a file (let's say "c:\temp\bitmap.jpg")
and instead of calling Image.FromStream(cstream) i call
Image.FromFile(c:\temp\bitmap.jpg")
the image is loaded succesfully!!!!!! and the save method of the image
Object
creates exactly the same image. With the text in it!!!!!!!

Please notice that i want the image object to pass it on an other function

Thank you for your time
Please help me
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Oq**************@TK2MSFTNGP14.phx.gbl...
Hi,

Think you are draw the string off the visible area of the bitmap.
This should work.
Dim bm As New Bitmap(50, 50)

Dim g As Graphics = Graphics.FromImage(bm)

g.Clear(Color.Black)

g.TranslateTransform(25, 25)

g.RotateTransform(90)

g.DrawString("Hi", Me.Font, Brushes.White, 0, 0)

Ken

--------------------------

"Programmer" <se*******@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Hi all
Here is my problem

I want to create an image so i can pass it on an object to put it as
watermark in my pdf report

Here is what i have write so far

Dim objBitmap As System.Drawing.Bitmap

Dim objGraphics As System.Drawing.Graphics

Dim cstream As System.IO.MemoryStream

Dim c As System.Drawing.Image

objBitmap = New System.Drawing.Bitmap(width, height)

objGraphics = System.Drawing.Graphics.FromImage(objBitmap)

Dim drawFont As New System.Drawing.Font("Arial", 32)

Dim drawBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Bla ck)

' Create point for upper-left corner of drawing.

Dim x As Single = 0.0F

Dim y As Single = 0.0F

' Set format of string.

Dim drawFormat As New System.Drawing.StringFormat

drawFormat.FormatFlags =
System.Drawing.StringFormatFlags.DirectionVertical

g.DrawString("IMAGE TEXT", drawFont, drawBrush, x, y, drawFormat)

objBitmap.save ("c:\temp\a.jpg")

objBitmap.Save(cstream, System.Drawing.Imaging.ImageFormat.Jpeg)

c = System.Drawing.Image.FromStream(cstream)

c.Save("c:\temp\b.jpg")

Now if you look at the a.jpg and b.jpg the a.jpg contains an image that
writes the "IMAGE TEXT"

but b.jpg is totaly BLACK!!!!!

What i'm doing wrong??

Thank you for your time


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve Amey | last post by:
Hi all I have an ARGB value for a Colour (Eg. -65536. The value was retrieved by using the Color.ToArgb method), is there any way that I can create a System.Drawing.Image or a...
2
by: Programmer | last post by:
Hi all Here is my problem I want to create an image so i can pass it on an object to put it as watermark in my pdf report Here is what i have write so far Dim objBitmap As...
6
by: David W. Simmonds | last post by:
I know that I can create an Image object by using a path like C:\MyPictures\pic.jpg, but how can I create an Image object by using a path like /MyPictures/pic.jpg where the path is relative to the...
2
by: Mango | last post by:
Hi there, I will be very happy if someone helps me. I need to create dynamic image, and save the state between the postback. I mean I've got 5 buttons and when I click on one of them, the image is...
4
by: John Daly | last post by:
Does anyone know how to create an image (JPEG) from an HTTPResponse object? I am working on system that has a map pop up from our GIS department. I want create an image at runtime from this popup...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
3
by: pedrito | last post by:
I've got an app that downloads images off the internet using anywhere from 1-20 threads concurrently (though generally around 4 threads). I have a preview page that shows the images as they're...
3
by: sanghavi | last post by:
how to create a set up project in vb.net..how to run an application on a different machine
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
11
by: =?Utf-8?B?UGV0ZXIgSw==?= | last post by:
I am working with Visual Studio or alternately with Expression Web. I need to create about 50 aspx pages with about 1200 thumbnali images, typically arranged in three to four groups per page,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.