Click here to Skip to main content
15,893,668 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to load wmf image Pin
Luc Pattyn18-Aug-07 11:19
sitebuilderLuc Pattyn18-Aug-07 11:19 
GeneralRe: How to load wmf image Pin
Christian Graus18-Aug-07 11:30
protectorChristian Graus18-Aug-07 11:30 
GeneralRe: How to load wmf image Pin
Luc Pattyn18-Aug-07 11:46
sitebuilderLuc Pattyn18-Aug-07 11:46 
GeneralRe: How to load wmf image Pin
Christian Graus18-Aug-07 12:36
protectorChristian Graus18-Aug-07 12:36 
GeneralRe: How to load wmf image [modified] Pin
John Andrew19-Aug-07 13:36
John Andrew19-Aug-07 13:36 
GeneralRe: How to load wmf image Pin
Luc Pattyn19-Aug-07 13:48
sitebuilderLuc Pattyn19-Aug-07 13:48 
AnswerRe: How to load wmf image Pin
Christian Graus18-Aug-07 11:30
protectorChristian Graus18-Aug-07 11:30 
AnswerRe: How to load wmf image Pin
Luc Pattyn18-Aug-07 11:54
sitebuilderLuc Pattyn18-Aug-07 11:54 
Hi,

I have been experimenting with the following C# code:

ADDED
remark: the wmf files are derived from the gif files (with Image.FromFile
and Image.Save); the jpg files are unrelated.
/ADDED

public void test() {
	testImageStream("image1.gif", "image2.gif");
	testImageStream("image1.jpg", "image2.jpg");
	testImageStream("image1.wmf", "image2.wmf");
}
 
public void testImageStream(string file1, string file2) {
	log(new string('-', 80));
	log("First create one stream containing two images");
	MemoryStream ms=new MemoryStream();
 
	byte[] bytes1=File.ReadAllBytes(file1);
	int len1=bytes1.Length;
	log("file1="+file1+", len="+len1+", size="+Image.FromFile(file1).Size);
	ms.Write(bytes1, 0, len1);
 
	byte[] bytes2=File.ReadAllBytes(file2);
	int len2=bytes2.Length;
	log("file2="+file2+", len="+len2+", size="+Image.FromFile(file2).Size);
	ms.Write(bytes2, 0, len2);
	try {
		log("trying without rewind, should fail");
		Image img1=Image.FromStream(ms);
		log("    img1="+img1.Size);
	} catch(Exception exc) {
		log(exc);
	}
	try {
		log("with explicit positioning");
		ms.Seek(0, SeekOrigin.Begin);
		Image img1=Image.FromStream(ms);
		ms.Seek(len1, SeekOrigin.Begin);
		Image img2=Image.FromStream(ms);
		log("    img1="+img1.Size+" img2="+img2.Size);
	} catch(Exception exc) {
		log(exc);
	}
	try {
		log("with only one rewind");
		ms.Seek(0, SeekOrigin.Begin);
		Image img1=Image.FromStream(ms);
		Image img2=Image.FromStream(ms);
		log("    img1="+img1.Size+" img2="+img2.Size);
	} catch(Exception exc) {
		log(exc);
	}
}


and this is the output it generates on VS2005 or .NET 2.0:

23:46:13.437      --------------------------------------------------------------------------------
23:46:13.453      First create one stream containing two images
23:46:13.468      file1=image1.gif, len=4315, size={Width=64, Height=131}
23:46:13.468      file2=image2.gif, len=1525, size={Width=40, Height=40}
23:46:13.484      trying without rewind, should fail
23:46:13.500          img1={Width=64, Height=131}
23:46:13.515      with explicit positioning
23:46:13.515          img1={Width=64, Height=131} img2={Width=64, Height=131}
23:46:13.531      with only one rewind
23:46:13.625          img1={Width=64, Height=131} img2={Width=64, Height=131}
23:46:13.640      --------------------------------------------------------------------------------
23:46:13.656      First create one stream containing two images
23:46:13.656      file1=image1.jpg, len=7766, size={Width=143, Height=176}
23:46:13.796      file2=image2.jpg, len=148762, size={Width=632, Height=868}
23:46:13.812      trying without rewind, should fail
23:46:13.828          img1={Width=143, Height=176}
23:46:13.843      with explicit positioning
23:46:13.843          img1={Width=143, Height=176} img2={Width=143, Height=176}
23:46:13.859      with only one rewind
23:46:13.875          img1={Width=143, Height=176} img2={Width=143, Height=176}
23:46:13.984      --------------------------------------------------------------------------------
23:46:14.000      First create one stream containing two images
23:46:14.015      file1=image1.wmf, len=4283, size={Width=64, Height=131}
23:46:14.031      file2=image2.wmf, len=1591, size={Width=40, Height=40}
23:46:14.125      trying without rewind, should fail
23:46:14.140          img1={Width=64, Height=131}
23:46:14.156      with explicit positioning
23:46:14.156          img1={Width=64, Height=131} img2={Width=64, Height=131}
23:46:14.359      with only one rewind
23:46:14.375          img1={Width=64, Height=131} img2={Width=64, Height=131}


so my conclusions are:

1. all image types tested behave identically
2. they all always rewind the stream, which is not how I understand the
documentation "The stream is reset to zero if this method is called successively
with the same stream."
It really seems to be "The stream is reset to zero then read".
3. I fail to see how your original post matches with my test.

Smile | :)




Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


GeneralRe: How to load wmf image [modified] Pin
Spejlo18-Aug-07 21:52
Spejlo18-Aug-07 21:52 
GeneralRe: How to load wmf image Pin
Luc Pattyn19-Aug-07 0:33
sitebuilderLuc Pattyn19-Aug-07 0:33 
QuestionHow to relate two tables in different data base Pin
Ashish Kumar Vyas18-Aug-07 4:13
Ashish Kumar Vyas18-Aug-07 4:13 
AnswerRe: How to relate two tables in different data base Pin
green2go18-Aug-07 13:35
green2go18-Aug-07 13:35 
QuestionDataGridView 2.0 [modified] Pin
Taylor Kobani18-Aug-07 2:34
Taylor Kobani18-Aug-07 2:34 
Questionhow to write ms word file using rtf formated data Pin
Salman Sheikh18-Aug-07 2:08
Salman Sheikh18-Aug-07 2:08 
AnswerRe: how to write ms word file using rtf formated data Pin
Paul Conrad18-Aug-07 3:30
professionalPaul Conrad18-Aug-07 3:30 
GeneralRe: how to write ms word file using rtf formated data Pin
Salman Sheikh20-Aug-07 1:29
Salman Sheikh20-Aug-07 1:29 
AnswerRe: how to write ms word file using rtf formated data Pin
Jwalant Natvarlal Soneji21-Aug-07 18:13
Jwalant Natvarlal Soneji21-Aug-07 18:13 
QuestionHow to use a kind or array of file path? Pin
Jwalant Natvarlal Soneji18-Aug-07 0:31
Jwalant Natvarlal Soneji18-Aug-07 0:31 
AnswerRe: How to use a kind or array of file path? [modified] Pin
Luc Pattyn18-Aug-07 0:39
sitebuilderLuc Pattyn18-Aug-07 0:39 
QuestionRe: How to use a kind or array of file path? Pin
Jwalant Natvarlal Soneji18-Aug-07 0:42
Jwalant Natvarlal Soneji18-Aug-07 0:42 
AnswerRe: How to use a kind or array of file path? Pin
Christian Graus18-Aug-07 0:46
protectorChristian Graus18-Aug-07 0:46 
AnswerRe: How to use a kind or array of file path? Pin
Luc Pattyn18-Aug-07 0:50
sitebuilderLuc Pattyn18-Aug-07 0:50 
AnswerRe: How to use a kind or array of file path? Pin
Christian Graus18-Aug-07 0:45
protectorChristian Graus18-Aug-07 0:45 
QuestionHow to print multiple images? Pin
Jwalant Natvarlal Soneji18-Aug-07 0:27
Jwalant Natvarlal Soneji18-Aug-07 0:27 
AnswerRe: How to print multiple images? Pin
Christian Graus18-Aug-07 0:47
protectorChristian Graus18-Aug-07 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.