BCB Components rotating around DirectX

Welcome to BCB-Tools.com Latest News

Development Tools Demo Applications Step-By-Step Tutorials Component Reference

Register Here Available Downloads

Frequently Asked Questions Discussion Forums Receive emails from BCB-Tools.com Send us some Feedback

Links to other sites Information about the BCB-Tools.com website


    FORUM MESSAGE
    Go to the Welcome Page
        FORUM MESSAGE

    You are reading a General forum message.

    Re: JPEG Component HELP..here you have a function that loads gif or jp

    Author: Israel Luengo

    Date Posted: 2004-12-17 07:57:45



    Hello Alex....

    here hoy have an example code that load an GIF or JPG in Timage in builder (ver. 1-6)
    (coded by a friend called Leo)


    - we add include statement: #include<olectl.h>

    Code:

    void CargarImagen(
        TImage *imagen,        // pointer to  TImage where we will load the image
        String nombreFichero)  // path of the file to load
    {
        // Formats: BMP, GIF, JPG, ICO, EMF, WMF

        const int HIMETRIC_INCH   = 2540;
        IPicture *pPicture = NULL;

        OleLoadPicturePath( StringToOleStr(nombreFichero),
            NULL, 0, 0, IID_IPicture, (void**)&pPicture;);

        // Now we load the image in the TImage
        if (pPicture)
        {
            imagen->Picture = NULL;
            long ancho, alto;
            pPicture->get_Width(&ancho;);
            pPicture->get_Height(&alto;);
            imagen->Picture->Bitmap->Width = MulDiv(ancho,
                GetDeviceCaps(imagen->Canvas->Handle, LOGPIXELSX), HIMETRIC_INCH);
            imagen->Picture->Bitmap->Height = MulDiv(alto,
                GetDeviceCaps(imagen->Canvas->Handle, LOGPIXELSY), HIMETRIC_INCH);
            RECT rect = imagen->ClientRect;
            pPicture->Render(imagen->Canvas->Handle, 0, 0,
                imagen->Picture->Bitmap->Width, imagen->Picture->Bitmap->Height,
                0, alto, ancho, -alto, ▭);
            pPicture->Release();
        }
    }


    Now to check...we must add a Timage (Image1 for example) with property AutoSize -> true, a TButton (Button1) on it's event OnClick the code follow:

        CargarImagen(Image1, "c:\\nuestroDir\\nuestraImagen.gif");

    we can add a second argument, a link to the image:

        CargarImagen(Image1, "http://cppbuilder.hypermart.net/leo.gif");

    that's all....thanks to Leo





    REPLY TO THIS MESSAGE?
    Top    

    You can post a reply to this General message using the form below:
    Your Name:


    Message Subject:


    Message Body:


    Verification:





    When ready, click on the submit button below:






Top

Welcome |  Latest News |  Tools |  Demos |  Tutorials |  Reference |  Register |  Downloads
FAQ |  Forums |  Feedback |  Mailing List |  Links |  Site Information

This page is Copyright © 2007 Darren John Dwyer, Australia. All Rights Reserved.
Borland C++ Builder, CBuilder, etc are Trademarks of Borland Corporation.
DirectX, DirectDraw, Windows, etc are Trademarks of Microsoft Corporation.