小编Jos*_*ter的帖子

为什么在将int复制到字节缓冲区时memcpy/memmove反向数据?

所以,我的问题非常简单:

我需要用一些信息填充char/unsigned char数组.中间的一些值取自short/int类型,这就是:

码:

int foo = 15; //0x0000000F
unsigned char buffer[100]={0};

..
memcpy(&buffer[offset], &foo, sizeof(int)); //either memmove
...
Run Code Online (Sandbox Code Playgroud)

输出:

... 0F 00 00 00 ..
Run Code Online (Sandbox Code Playgroud)

所以到现在为止我编写了一个函数来反转这些字段,但我认为这不是一个聪明的解决方案,因为它会影响执行时间,资源和开发时间.

有更简单的方法吗?

编辑:正如你们许多人所指出的,这种行为是由于小端处理器产生的,但我的问题仍然存在.我需要在big-endian中使用int/short值来填充此缓冲区,因为我需要将数据序列化以传输到以小/大端工作的机器,因为此协议已经定义,所以无关紧要.

注意:用于在C++中进行编译

c c++

5
推荐指数
2
解决办法
5020
查看次数

无法使用 MigraDoc/PDFsharp 打印

我将 NuGet 包添加到我的项目中:

PDFsharp + MigraDoc

版本:1.50.4790-beta5a(预发行)

添加了参考文献:

MigraDoc.DocumentObjectModel

MigraDoc.Rendering

MigraDoc.RtfRendering

pdfSharp

PdfSharp.图表

我正在使用 VS2013,针对 .NET Framework 4.5。

没有MigraDocPrintDocument类/命名空间,也没有Printing.MigraDocPrintDocument ...

另外,我尝试将PagePreview控件添加到我的表单中(我正在开发 Windows.Forms 应用程序),但没有这样的控件,也无法将此类项目从 dll/包添加到我的工具箱中。

我已经将 PDF 文档制作得非常简单,但现在我陷入了最后一步,看不到曙光。需要打印到热敏打印机。

我的代码的一小段:

public void PrintMigraDoc(Bitmap ImagenBMP, string nombre, string apellido, string documento, string nacimiento, string nacionalidad, string grupo)
{
    //Save image in greyscale
    Bitmap bmp = GrayScale(ImagenBMP);
    bmp.Save("foto_grey.bmp");
    
    //Create document
    Document document = new Document();
    //Custom Normal Style
    Style style = document.Styles["Normal"];
    style.Font.Name = "Calibri";
    style.Font.Size = 6;

    //Sections …
Run Code Online (Sandbox Code Playgroud)

c# pdf visual-studio migradoc

1
推荐指数
1
解决办法
5191
查看次数

标签 统计

c ×1

c# ×1

c++ ×1

migradoc ×1

pdf ×1

visual-studio ×1