Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2006, 01:09 AM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default HowTo_Net_Drawing_Framework

Just a start.... For several years, you have been a source of outstanding information. I've learned a great deal!

Now,with your example code above and reading your book, I'm stumped as to how to serialize a jpg picture? Possible? Your sample is exactly what I was looking for except, i don't understand the ".pic" extension and would like to use jpg's instead. You can create a New picture and save it "Testing.pic" but can't open it in Paint for example.

I'll keep reading but can you share any ideas that would be helpful.

Thanks Again

Larry

 
Old October 26th, 2006, 08:06 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Hi Larry,

Which example are you using? What page is it on?

A serialization is an encoding of some other data that you can later deserialize to recover the original data. If you serialize a picture, you need to deserialize it before you can treat it like a picture again and display it. You wouldn't be able to open it in Paint or any other picture viewing program until you deserialize it.

Does that help? Or is that not what you're trying to do?

Rod


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old October 26th, 2006, 05:18 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I just figured out that this code snippet wasn't from your book, (I have) but from your vb-helper web site.
Now I understand the purpose of serializing data and it makes sense to me. Allows working with layers I suspect. Here's the snippet I'm having a problem with.
Dim xml_serializer As New XmlSerializer(GetType(DrawablePicture))
Dim file_stream As New FileStream(file_name, FileMode.Open)
Dim new_picture As DrawablePicture = _
 DirectCast(xml_serializer.Deserialize(file_stream) , DrawablePicture)
The above is from the DrawablePicture.class.
I hope I'm not just throwing you for a loop.
Thanks


 
Old October 27th, 2006, 09:01 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

The result of that should be a new DrawablePicture object. The program should then be able to use it to draw whatever was in it when it was serialized.

DrawablePicture is a class defined in the program, however, it's not a standard image format such as bmp or jpeg. If you want to be able to display the image in Paint or some other program, you would need to draw the image onto a bitmap and the save the bitmap into a file. The Bitmap class's Save method should be able to do that. For details on that part, see this example:

    http://vb-helper.com/howto_net_savepicture.html

Rod

Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old October 30th, 2006, 12:27 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I just re-read chapters 19-22 and sure enough, it works super!
With this little bit of code...
Code:
Dim bm As New Bitmap(PictureBox1.DisplayRectangle.Width,  PictureBox1.DisplayRectangle.Height)
bm = PictureBox1.Image
Dim g As Graphics = Graphics.FromImage(bm)
Thanks Greatly
Larry

 
Old November 18th, 2006, 03:46 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This guys deserves a little attention:

http://www.codeproject.com/vb/net/Fr...53&msg=1764153

He completely ripped off Mr. Stephens' work and published it as his own (did not even change the comments and variable names).










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.