<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:DengXian;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Yes. It works well.</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">发送自<span lang="EN-US"> Windows 10 </span>版<span lang="EN-US"><a href="https://go.microsoft.com/fwlink/?LinkId=550986"><span lang="EN-US"><span lang="EN-US">邮件</span></span></a></span>应用</p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p> </o:p></span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>发件人:</b> Frediano Ziglio <fziglio@redhat.com><br>
<b>发送时间:</b> Wednesday, June 20, 2018 8:11:58 PM<br>
<b>收件人:</b> 谢昆明<br>
<b>抄送:</b> 谢 昆明; spice-devel@lists.freedesktop.org; Christophe Fergeau<br>
<b>主题:</b> Re: 答复: [Spice-devel] 答复: how to open jpg binary file (/tmp/spice_dump/x.jpg)?</font>
<div> </div>
</div>
<div>
<div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000">
<div>Can you try this patch?<br>
</div>
<div><br>
</div>
<div>diff --git a/common/canvas_base.c b/common/canvas_base.c<br>
index 957f887..ae064ca 100644<br>
--- a/common/canvas_base.c<br>
+++ b/common/canvas_base.c<br>
@@ -438,9 +438,9 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,<br>
<br>
//#define DUMP_JPEG<br>
#ifdef DUMP_JPEG<br>
-static int jpeg_id = 0;<br>
-static void dump_jpeg(uint8_t* data, int data_size)<br>
+static void dump_jpeg(SpiceChunks* data, uint32_t data_size)<br>
{<br>
+ static uint32_t jpeg_id = 0;<br>
char file_str[200];<br>
uint32_t id = ++jpeg_id;<br>
<br>
@@ -455,9 +455,13 @@ static void dump_jpeg(uint8_t* data, int data_size)<br>
return;<br>
}<br>
<br>
- fwrite(data, 1, data_size, f);<br>
+ for (uint32_t n = 0; n < data->num_chunks; ++n) {<br>
+ fwrite(data->chunk[n].data, 1, data->chunk[n].len, f);<br>
+ }<br>
fclose(f);<br>
}<br>
+#else<br>
+static inline void dump_jpeg(SpiceChunks* data, uint32_t data_size) {}<br>
#endif<br>
<br>
static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)<br>
@@ -486,9 +490,7 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)<br>
<br>
canvas->jpeg->ops->decode(canvas->jpeg, dest, stride, SPICE_BITMAP_FMT_32BIT);<br>
<br>
-#ifdef DUMP_JPEG<br>
dump_jpeg(image->u.jpeg.data, image->u.jpeg.data_size);<br>
-#endif<br>
return surface;<br>
}<br>
<br>
@@ -665,9 +667,7 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *ima<br>
}<br>
lz_decode(lz_data->lz, LZ_IMAGE_TYPE_XXXA, decomp_alpha_buf);<br>
<br>
-#ifdef DUMP_JPEG<br>
dump_jpeg(image->u.jpeg_alpha.data, image->u.jpeg_alpha.jpeg_size);<br>
-#endif<br>
return surface;<br>
}<br>
</div>
<div>Frediano<br>
</div>
<div><br>
</div>
<hr id="zwchr">
<blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">
<style><!--
@font-face
{font-family:Helvetica;
panose-1:2 11 5 4 2 2 2 2 2 4;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:DengXian;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Fix bug.</span><span style="font-size:12.0pt" lang="EN-US"></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal">发送自<span lang="EN-US"> Windows 10 </span>版<span lang="EN-US"><a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank"><span lang="EN-US"><span lang="EN-US">邮件</span></span></a></span>应用</p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:SimSun" lang="EN-US"> </span></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b>发件人<span lang="EN-US">: </span>
</b><span lang="EN-US"><a href="mailto:fziglio@redhat.com" target="_blank">Frediano Ziglio</a><br>
</span><b>发送时间<span lang="EN-US">: </span></b><span lang="EN-US">2018</span>年<span lang="EN-US">6</span>月<span lang="EN-US">20</span>日<span lang="EN-US"> 18:32<br>
</span><b>收件人<span lang="EN-US">: </span></b><span lang="EN-US"><a href="mailto:KunMing.Xie@hotmail.com" target="_blank"><span lang="EN-US"><span lang="EN-US">谢</span></span><span lang="EN-US"><span lang="EN-US">
</span></span><span lang="EN-US"><span lang="EN-US">昆明</span></span></a><br>
</span><b>抄送<span lang="EN-US">: </span></b><span lang="EN-US"><a href="mailto:spice-devel@lists.freedesktop.org" target="_blank">spice-devel@lists.freedesktop.org</a>;
<a href="mailto:cfergeau@redhat.com" target="_blank">Christophe Fergeau</a><br>
</span><b>主题<span lang="EN-US">: </span></b><span lang="EN-US">Re: [Spice-devel] </span>
答复<span lang="EN-US">: how to open jpg binary file (/tmp/spice_dump/x.jpg)?</span></p>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:SimSun" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt;text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Helvetica",sans-serif;color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">Yes. It is some spice code which is calling dump_jpeg.</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">After apply this patch, jpeg file can be open by eog.</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US">The call is correct. What is wrong is dump_jpeg which should handle all chunks and not assume that pointer</span></p>
</div>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US">is raw data.</span></p>
</div>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US">Thanks for the report.</span></p>
</div>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US">What are you trying to do dumping jpeg images?</span></p>
</div>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US"> </span></p>
</div>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US">Frediano</span></p>
</div>
<div>
<p class="MsoNormal" style="text-align:left" align="left"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:black" lang="EN-US"> </span></p>
</div>
<blockquote style="border:none;border-left:solid #1010FF 1.5pt;padding:0cm 0cm 0cm 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black">发送自<span lang="EN-US"> Windows 10
</span>版<span lang="EN-US"><a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank"><span lang="EN-US"><span lang="EN-US">邮件</span></span></a></span>应用<span lang="EN-US"></span></span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="font-size:12.0pt;font-family:SimSun;color:black" lang="EN-US"> </span><span style="color:black" lang="EN-US"></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:3.75pt"><b><span style="color:black">发件人<span lang="EN-US">:
</span></span></b><span style="color:black" lang="EN-US"><a href="mailto:cfergeau@redhat.com" target="_blank">Christophe Fergeau</a><br>
</span><b><span style="color:black">发送时间<span lang="EN-US">: </span></span></b><span style="color:black" lang="EN-US">2018</span><span style="color:black">年<span lang="EN-US">6</span>月<span lang="EN-US">20</span>日<span lang="EN-US"> 17:28<br>
</span><b>收件人<span lang="EN-US">: </span></b><span lang="EN-US"><a href="mailto:KunMing.Xie@hotmail.com" target="_blank"><span lang="EN-US"><span lang="EN-US">谢</span></span><span lang="EN-US"><span lang="EN-US">
</span></span><span lang="EN-US"><span lang="EN-US">昆明</span></span></a><br>
</span><b>抄送<span lang="EN-US">: </span></b><span lang="EN-US"><a href="mailto:spice-devel@lists.freedesktop.org" target="_blank">spice-devel@lists.freedesktop.org</a><br>
</span><b>主题<span lang="EN-US">: </span></b><span lang="EN-US">Re: [Spice-devel] how to open jpg binary file (/tmp/spice_dump/x.jpg)?</span></span></p>
</div>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="font-size:12.0pt;font-family:SimSun;color:black" lang="EN-US"> </span><span style="color:black" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">Hey,</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">On Wed, Jun 20, 2018 at 02:14:54AM +0000,
</span><span style="color:black">谢 昆明<span lang="EN-US"> wrote:</span></span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> Hey guys. I have dump some jpg file, but I can</span><span style="color:black">’<span lang="EN-US">t open it with eog.</span></span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">I don't understand how this relates to spice? Is this some spice code</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">which is calling dump_jpeg?</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">Christophe</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> static int jpeg_id = 0;</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> static void dump_jpeg(uint8_t* data, int data_size)</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> {</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> char file_str[200];</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> uint32_t id = ++jpeg_id;</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> #ifdef WIN32</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> sprintf(file_str, "c:\\tmp\\spice_dump\\%u.jpg", id);</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> #else</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> sprintf(file_str, "/tmp/spice_dump/%u.jpg", id);</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> #endif</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> FILE *f = fopen(file_str, "wb");</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> if (!f) {</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> return;</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> }</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> fwrite(data, 1, data_size, f);</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> fclose(f);</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">> }</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span></p>
<p class="MsoNormal" style="margin-left:3.75pt"><span style="color:black" lang="EN-US">>
</span><span style="color:black">发送自<span lang="EN-US"> Windows 10 </span>版邮件<span lang="EN-US"><https://go.microsoft.com/fwlink/?LinkId=550986></span>应用<span lang="EN-US"></span></span></p>
</blockquote>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:36.0pt;margin-bottom:5.0pt;margin-left:3.75pt">
<span style="color:black" lang="EN-US">> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
</div>
</blockquote>
<div><br>
</div>
</div>
</div>
</body>
</html>