请问各位大虾如何用Delphi写读取及转换raw图片的程序??

解决方案 »

  1.   

    http://delphi.137bbs.com/simple/index.php?t77010.html
      

  2.   

    再问各位老大,raw的读取格式为mac时怎么处理啊??
      

  3.   

    4 bytes
    big endian 
    (Mac style)这种raw图片应该怎么处理啊?
      

  4.   

    主要问题还是上面所说的,4 bytes big endian (Mac style)格式转换为little endian的问题
      

  5.   

    无语,这么简单的位运算问题,到了现在居然成了难题function BSWAP4B(n:Cardinal):Cardinal;
    begin
      Result:= (n shr 24)
          or ((n shr 8) and $0000FF00)
          or ((n shl 8) and $00FF0000)
          or (n shl 24);
    end;如果是x86体系,还可以用bswap指令:function BSWAP4B_ASM(n:Cardinal):Cardinal;
    asm
      mov eax, n  // 将变量加载到EAX寄存器
      bswap eax // 字节交换
      // EAX是函数返回值
    end;
      

  6.   

    不好意思啊,我又有问题了:
    一raw图象,此raw图象在photoshop下打开时参数设置为:长 宽 16位 byte order:mac  则打开为"灰色"图象,一切正常.
    但我按照http://delphi.137bbs.com/simple/index.php?t77010.html的方法转换一raw图象为16位bmp格式,转换后如果不进行4 bytes big endian (Mac style)格式转换,图片和photoshop下转出来的不一样,转出来的图象是彩色的,而且方向也不对,但是进行了4 bytes big endian (Mac style)格式转换后,转出来的图象就更不对了,还是彩色(基本是绿色),且图象非常不正常,内容完全看不出来是什么!请大家帮我分析一下是怎么回事!!
      

  7.   

    前面说得有点不清楚,其实我想问的问题就是:16位灰度、 mac style的raw图象数据怎样转化为bitmap!!??
      

  8.   

    #include <stdio.h>
    #include<stdlib.h>
    static unsigned char ii[128][128];
    int Row=128,Col=128;
    char file_name[40];
    Load_data_file()
    {
    int f1;
    int i,n;
    unsigned long offbits;
    FILE *fp;
    printf("Please input original file name :");
    scanf("%s",file_name);
    f1=Col*Row;
    if((fp=fopen(file_name,"rb"))==0)
    {
    printf("Cannot open file,push any key!\n");
    putchar(0x07);
    getchar();
    exit(0);
    }
    fseek(fp,10L,0);
    fread(&offbits,4,1,fp);
    printf("offBits=%ld\n",offbits);
    printf("press any key to continue\n");
    putchar(0x07);
    getchar();

    fseek(fp,offbits,0);
    if(fread(ii,1,f1,fp)!=f1)
    {
    printf("File read error\n");
    putchar(0x07);
    getchar();
    exit(0);
    }
    fclose(fp);

    };
    void main()
    { FILE * fp;
    unsigned char oi[128][128];
    int f2=Col*Row,i,j;
    Load_data_file();
    for(i=0;i<Row;i++)
    for(j=0;j<Col;j++)
    {
    oi[i][j]=ii[Row-i-1][j];
    printf("%d   ",oi[i][j]);
    }
    printf("\n");printf("Input save file name:");
    scanf("%s",file_name);
    if((fp=fopen(file_name,"wb"))==0)
    {
        printf("Cannot open file\n");
        return;
    }
    if(fwrite(oi,1,f2,fp)!=f2)
    printf("File write error\n");
    fclose(fp);
    getchar();
    return;
    }