Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Using Windows GDI+ (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: FSpCreate crashes in a Carbon plugin
Next thread: How make empty REALstring ?


macosx and unix paths   -   GOLD
  Using Windows GDI+   -   Suikyo
   Re: Using Windows GDI+   -   Suikyo
    Re: Using Windows GDI+   -   William Yu

Using Windows GDI+
Date: 02.06.05 10:23 (Thu, 02 Jun 2005 18:23:56 +0900)
From: Suikyo
Hello.

I intended to use GDI+ without using Quicktime to unify reading of an
image.
Therefore I compiled the following cords.
Compiling it is normal, but REALbasic shuts it down when I carry it out.

Will you work normally if you fix where?

-------------------------------------------------------------------
using namespace Gdiplus;

REALpicture CLoadImage(REALobject instance,REALfolderItem src)
{
REALpicture buf;
REALgraphics graphics;
HDC hdc;
LPCSTR path;

//get and appry
ClassData(GDIClass, instance, stGDIPlus, data);

//store LPCSTR
path = REALConvertString(REALpathFromFolderItem(src),0x420)->CString();

//for multi-byte user
WCHAR wFilename[1024] = {0};
mbstowcs(wFilename, (LPCTSTR)path, strlen(path)+1);

//load any type image
Image image(wFilename);

//build picture
buf = REALNewPicture(120,120,32);
if(buf=iLL){
return nil;
}

//get picture's graphics
graphics = REALGetPictureGraphics( buf );
if(graphics=RLL)
{
REALUnlockObject( (REALobject)graphics );
return(nil);
}

//get windows device-context
hdc = REALGraphicsDC( graphics );
if (hdc =)ULL)
{
REALUnlockObject( (REALobject)graphics );
return(false);
}

//create GDI++ Graphics from HDC
Graphics gdig(hdc);

//draw Image to context
gdig.DrawImage( &image, 0, 0 );//$BIA2h(B

//free
REALUnlockObject( (REALobject)graphics );

//return picture
return buf;
}

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Using Windows GDI+
Date: 04.06.05 09:09 (Sat, 04 Jun 2005 17:09:06 +0900)
From: Suikyo
Hello.

I develop the plug in that used GDI+.

The first caller succeeds, but the second caller makes a blunder. Why?
----------------------------------------------------------------------
REALclassDefinition GDIClass = {
kCurrentREALControlVersion,
"GDIPlus",
nil,
sizeof(stGDIPlus),
0,
(REALproc) CGDIPlusConstructor,// constructor
(REALproc) CGDIPlusDestructor,// destructor
0, 0,
CGDIPlusMethods,
sizeof(CGDIPlusMethods) / sizeof(REALmethodDefinition),
};
----------------------------------------------------------------------
REALmethodDefinition CGDIPlusMethods[] = {
{ (REALproc)CLoadImage,
REALnoImplementation,
"LoadImage(f as FolderItem) As Picture"
},
}
----------------------------------------------------------------------
REALpicture CLoadImageWith(REALobject instance,REALfolderItem src,UINT
width,UINT height){
ClassData(GDIClass, instance, stGDIPlus, data);

REALpicture buf;
REALgraphics graphics;
HDC hdc;
REALstring path;
UINT iwidth,iheight;

path = REALpathFromFolderItem(src);
Image* pImage = Image::FromFile( mConvertREALstringToWideChar(path) );
if(pImage= LL){
data->LastError = IMAGE_LOAD_FAILED;
return(nil);
}
if(width =i1||height =)1){
iwidth = pImage->GetWidth();
iheight = pImage->GetHeight();
}else{
iwidth = width;
iheight = height;
}
buf = REALNewPicture(iwidth,iheight,32);
if(buf= LL){ return(nil); }
graphics = REALGetPictureGraphics( buf );
if(graphics = ULL){
REALUnlockObject((REALobject)graphics);
return(nil);
}
hdc = REALGraphicsDC( graphics );
if (hdc =cULL){
REALUnlockObject((REALobject)graphics);
return(nil);
}
Graphics gdig(hdc);
gdig.DrawImage( pImage, 0, 0, iwidth, iheight );
REALUnlockObject( (REALobject)graphics );
delete pImage;

return buf;
}
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Using Windows GDI+
Date: 04.06.05 20:48 (Sat, 04 Jun 2005 14:48:15 -0500)
From: William Yu
On 6/4/05 3:09 AM, "Suikyo" <<email address removed>> wrote:

> Hello.
>
> I develop the plug in that used GDI+.
>
> The first caller succeeds, but the second caller makes a blunder. Why?

Can you step through the code and see which line it's crashing on? If you
have the Windows IDE, debugging a DLL using CW is pretty simple. Just set
the target path to the Plugins folder and then the target app to launch to
REALbasic.

Regards,
William Yu
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>