Question Creating Image of form larger then allowed res

Automator

New member
Joined
Jun 22, 2010
Messages
2
Programming Experience
Beginner
[Background Info]
I created 2 programs (a Scheduler and Viewer) to create and maintain schedules to be displayed on large screen monitor for staff members. (42" and 52" screens). The viewer program auto scales and looks great on the larger screens however due to network configuration/drive share problems I need to try to create a way to display the schedule on a webpage.

I've been working on drawing the form to a bmp file and having a simple webpage display the image and refresh every so often to catch the changes.


[Problem]
I'm using bitblt to draw to a bmp file which works great however it creates a image at 1280x977 (my res minus the start bar space). When that imaged is stretched onto a 52" screen the image becomes unreadable.


[Question]
Is there a way to take a higher resolution image of a form so i can stretch it with out a loss of quality?
or
Is there a better way that I could easily push the schedule to a webpage from with in a vb.net program?


[Notes]
I've been learning VB.net on my own for about a year now and have little to no exp with creating WebPages. I know about enough to display an image full screen and reload the page every X seconds :p


Any helps, suggestions, or ideas on how to approach this would be great!
Thanks in advance
 
Hi Automator,

I could swear I've been able to make forms bigger than the screen in the past, but I can't do it know. I believe it's controlled by the OS. Maybe it came in with XP-sp2 or sp3.

Anyway, I can think of two ways you could go about this. Firstly there's the quick and dirty method which you are already using: capture the form surface and blow it up. Maybe you can make it a little bit less dirty (if you aren't already doing so) by using a higher quality Graphics.InterpolationMode such as HighQualityBicubic. Suppose your target size is 3500 pixels width and you want to keep the original aspect ratio:
VB.NET:
Dim bigBitmap As New Bitmap(3500, Cint(3500 * captureBitmap.Height / captureBitmap.Width))
Using g As Graphics = Graphics.FromImage(bmp)
   g.InterpolationMode=InterpolationMode.HighQualityBicubic
   g.DrawImage(captureBitmap, New Rectangle(Point.Empty, bigBitmap.Size))
End Using
Then you can save bigBitmap or do whatever you like with it.

Secondly, although you can't make the form bigger than the screen, that limitation doesn't apply to controls on the form. If it's just one control (say a DataGridView) you can simply set its size to the target size and give it a bigger font. Then you can render the control to a full resolution bitmap with its DrawToBitmap method. That works for practically any control except the RichTextBox.

If you want to make a layout with several controls, it's probably easiest to add TableLayoutPanel to the form in the Designer, do your layout in that, and then blow it up to the target resolution in code. Any controls which are fully docked or anchored into the TableLayoutPanel cells will be blown up proportionally.

If you want to check what the final image will look like while in the Designer, for example to choose a suitable target font size, make the form AutoScroll and leave the TLP Dock=DockStyle.None. Then you can set the TLP to the target size in the Properties window and scroll it around to see how it looks at full resolution.

Here's an example of how you could blow the TLP up and save it full-res as a file:
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TableLayoutPanel1.Size = New Size(3500, 2500)
        TableLayoutPanel1.Font = New Font(TableLayoutPanel1.Font.FontFamily, 72, FontStyle.Regular, GraphicsUnit.Point)
        Using bmp As New Bitmap(3500, 2500)
            TableLayoutPanel1.DrawToBitmap(bmp, New Rectangle(Point.Empty, bmp.Size))
            bmp.Save("E:\Pictures\BigLayout.Png", Imaging.ImageFormat.Png)
        End Using
    End Sub
Of course, you don't get the Form border that way. If you want it in your target image, you could use a combination of the two methods: blow up a captured image of the form border and paste in the full-res controls layout.

I don't know how you can push the image to a webpage, but maybe someone else here can tell you that.

VicJ
 
Automater,

You sound really creative - but I reckon in my opinion your idea of compiling an screen capture of the form on to an HTML page through a network is maybe not such a good idea. If your network is a large company, and has many connections throughout, then reloading a new bitmap image in a web browser every few seconds would most likely slow down your network - as well as to mention that the bitmap, due to it being a bitmap, would not appear instantly on your large screens.

Have you thought of rendering HTML pages on to a shared server directory, and having an internet browser reload the page every, say 5 seconds? If you have fair knowledge in HTML, you can set your application to write to an HTML file.

If not that, then stick to your original idea of having a Scheduler and a Viewer, using the network to your advantage by transferring the values you want to display on your larger screens through System.Net.Sockets?

I personally think that using bitmaps would be both painstaking, and would have a speed impact on your network. :)

Hope I have helped.
 
First off thank you for all the suggestions.

Well I'm not very good with HTML or any of the commonly used code bases for webpage creation (java,php,asp...) so I can't do anything to crazy on that end. However would it be possible to setup a webpage that could check if the image has changed sinec last reload and then not reload the image if it hasn't change?

The Image will only be updated when someone edits a schedule and clicks a "Publish to webpage" button inside the application. At which time the application will create an img of the schedule and save it in the webpage's image folder.

So if there is some way to prevent the webpage from reloading the image until it has changed then that would greatly reduce the network traffic. I might also be able to get away with using a 1200x1080 resolution image which will also help. (the bmp format comes in at about 5mb and a png format is 100k but little less quality)
 

Latest posts

Back
Top