How to load picture in C Program.

You can make use of OleLoadPicture function. This function converts different formats not only gif file format but .jpg, .bmp, .ico, .emf, .wmf into an IPicture interface. Then you can make use of IPicture::Render function to display the picture.

Try and let us know whether you could succeed.

Related Links :

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. hello i am trying to send a bmp file through socket this is the sender but for a reason my buffers do not other bits than 0 or 255 and my image is white ...could someone help me please




    #include /* for type definitions */
    #include /* for socket API function calls */
    #include /* for address structs */
    #include /* for sockaddr_in */
    #include /* for printf() */
    #include /* for atoi() */
    #include /* for strlen() */
    #include /* for close() */
    #include
    #include
    #include
    #include
    #include
    #include

    int main (int argc,char **argv)
    {
    int error;
    int s;
    int q,w,e,r;
    unsigned char buf1 [49152];
    unsigned char buf2 [49152];
    unsigned char buf3 [49152];
    unsigned char buf4 [49152];

    size_t len;
    FILE * fp;
    unsigned long cnt,im_row,im_col;
    unsigned char tc;
    unsigned int w1,w2,width,height,h1,h2,offset,bpp,j;
    unsigned int padd,i,l;
    unsigned char image[256][256][3];
    unsigned char tmpim[196608];

    struct addrinfo hint, *res;
    struct addrinfo *multi;

    memset( &hint, 0, sizeof( hint ) );
    hint.ai_family = AF_INET6;
    hint.ai_socktype = SOCK_DGRAM;
    hint.ai_protocol = 0;

    error = getaddrinfo( "ff02::1", NULL, &hint, &res );

    if( error != 0 ) {
    perror( "getaddrinfo" );

    }

    struct sockaddr_in6 * addr = (struct sockaddr_in6*)res->ai_addr;
    addr->sin6_port = htons( 7890 );
    addr->sin6_scope_id = 2; // 2 happens to be the interface ID
    s = socket( AF_INET6, SOCK_DGRAM, 0 );

    if ( !(fp=fopen("Anemos.bmp","rb")))
    {
    printf("Unable to load bin file: %s...\n","Anemos.bmp");
    }
    else
    {
    cnt = 0;
    im_row=0;
    im_col=0;
    while (!feof(fp)) {
    tc = fgetc(fp) & 0x0ff;

    if (cnt==10) offset=tc;
    if (cnt==18) w1=tc;
    if (cnt==19) w2=tc;
    if (cnt==22) h1=tc;
    if (cnt==23) h2=tc;
    if (cnt==28) bpp=tc;
    if ((cnt==30)&&(tc>0)) printf("ERROR!! Cannot Handle BMP files with Compression!!!\n");
    if (cnt==53) break;

    cnt++;
    }
    }

    width = w1+w2*256;
    height = h1+h2*256;

    int BMPRES_X = width;
    int BMPRES_Y = height;

    padd = 0;
    printf("W:%d, H:%d Image Data Starts at:%d with %d bits/pixel \n",width,height,offset,bpp);

    for ( im_row=0;im_rowai_addr, res->ai_addrlen ) !=49152) {
    printf( "Error sending buf1\n" );
    printf(" afou dn stalthike o protos buffer tote diakoptete i apostoli\n");
    exit(1);
    } else printf("Buf1 OK! \n",buf1);



    if( sendto( s, buf2, 49152, 0, res->ai_addr, res->ai_addrlen ) !=49152) {
    printf( "Error sending buf2\n" );
    } else printf("Buf2 OK!\n");


    if( sendto( s, buf3, 49152, 0, res->ai_addr, res->ai_addrlen ) !=49152) {
    printf( "Error sending buf3\n" );
    } else printf("Buf3 OK!\n");

    if( sendto( s, buf4, 49152, 0, res->ai_addr, res->ai_addrlen ) !=49152) {
    printf( "Error sending buf4\n" );
    }else printf("Buf4 OK!\n");

    exit(1);
    }

    ReplyDelete


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!