[DEVELOPMENT ENVIRONMENT]

* NEW: Replace Image.Draw() by Image.PaintImage() everywhere.

[WEB SITE MAKER]
* NEW: Some website updates.

[GB.GTK]
* NEW: The Image.Draw() method has been renamed as Image.PaintImage().

[GB.IMAGE]
* NEW: Image.DrawImage() is a new method that draws an image by ignoring
  the alpha channel.

[GB.IMAGE.IMLIB]
* NEW: The Image.Draw() method has been renamed as Image.PaintImage().

[GB.QT4]
* NEW: The Image.Draw() method has been renamed as Image.PaintImage().


git-svn-id: svn://localhost/gambas/trunk@3744 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-04-10 21:27:34 +00:00
parent c529c78553
commit 186afc6326
18 changed files with 369 additions and 385 deletions

View File

@ -37,14 +37,14 @@ SearchString=True
[OpenFile]
File[1]="gambas.sourceforge.net/architecture.html:37.33"
File[2]="gambas.sourceforge.net/style.css:266.0"
Active=3
File[3]="gambas.sourceforge.net/style-rtl.css:278.0"
File[2]="gambas.sourceforge.net/style.css:442.0"
File[3]="gambas.sourceforge.net/style-rtl.css:366.20"
File[4]="gambas.sourceforge.net/compilation.html.template#:2.0"
File[5]=".src/MMain.module:334.3"
File[6]="gambas.sourceforge.net/menu.html:89.27"
Active=6
File[6]="gambas.sourceforge.net/menu.html:73.9"
File[7]="gambas.sourceforge.net/home.html:0.0"
File[8]="gambas.sourceforge.net/home.html.template:43.224"
File[8]="gambas.sourceforge.net/home.html.template:50.40"
Count=8
[Watches]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -47,10 +47,11 @@
</div>
<div id="home-background">
<div align="center">
<img src="home.png" style="margin-top:16px;">
<img src="home.png" style="margin-top:32px;">
</div>
<div id="home-background">
</div>
<script type="text/javascript">

View File

@ -47,10 +47,11 @@
</div>
<div id="home-background">
<div align="center">
<img src="home.png" style="margin-top:16px;">
<img src="home.png" style="margin-top:32px;">
</div>
<div id="home-background">
</div>
<script type="text/javascript">

View File

@ -42,7 +42,7 @@
<br>
<div align="center">
<a class="image" href="../en/main.html" target="_top"><img src="flag/en.png" border="0" style="" alt="{English}" title="{English}"></img></a>
<a class="image" href="../en/main.html" target="_top"><img src="flag/en.png" border="0" style="" alt="{English}" title="{English}" valign="top"></img></a>
<a class="image" href="../fr/main.html" target="_top"><img src="flag/fr.png" border="0" style="" alt="{French}" title="{French}"></img></a>
<a class="image" href="../es/main.html" target="_top"><img src="flag/es.png" border="0" style="" alt="{Spanish}" title="{Spanish}"></img></a>
<a class="image" href="../de/main.html" target="_top"><img src="flag/de.png" border="0" style="" alt="{German}" title="{German}"></img></a>
@ -64,15 +64,15 @@
<a class="image" href="http://petition.eurolinux.org/" target="_blank"><img src="nopatents.png" border="0" alt="{No software patents in Europe!}" title="{No software patents in Europe!}"> </a>
<div style="height:12px;"></div>
<div style="height:6px;"></div>
<a class="image" href="http://sourceforge.net/" target="_blank"><img src="sourceforge.png" border="0" alt="SourceForge.net"></a>
<div style="height:6px;"></div>
<!--<div style="height:6px;"></div>
<img src="http://www.mypagerank.net/services/pagerankbutton/pagerankbutton.php?aut=ce471354aefc3a870d94ec9854231a105640443aa060e94f390c6cc1d2" border="0" alt="Powered by MyPagerank.Net">
<div style="height:16px;"></div>
-->
<div style="height:10px;"></div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:0px;">
<input type="hidden" name="cmd" value="_s-xclick">

View File

@ -364,8 +364,7 @@ p {
padding: 0px 16px 16px 8px;
border-bottom: dotted black 6px;
margin-right: -8px;
/*border-right: dotted black 6px;*/
/*border-radius: 0px 0px 12px;*/
background: white;
}
.title {
@ -471,11 +470,12 @@ a.download-blue:hover {
#home-background {
background-image: url('home.jpeg');
background-repeat: no-repeat;
background-position: 0px 0px;
margin-right: -8px;
background-position: bottom center;
margin-left: -8px;
margin-top: 8px;
position: absolute;
z-index: -1;
width: 868px;
height: 480px;
height: 90%;
bottom: 0px;
}

View File

@ -297,30 +297,6 @@ H3 {
margin-left: 16px;
}
.top-left-corner {
float: left;
}
.top-right-corner {
float: right;
}
.bottom-left-corner {
float: left;
}
.bottom-right-corner {
float: right;
}
.top-corner {
height: 8px;
}
.bottom-corner {
height: 8px;
}
img {
border: none;
}
@ -455,11 +431,12 @@ a.download-blue:hover {
#home-background {
background-image: url('home.jpeg');
background-repeat: no-repeat;
background-position: 0px 0px;
background-position: bottom center;
margin-left: -8px;
margin-top: 8px;
position: absolute;
z-index: -1;
width: 868px;
height: 480px;
height: 90%;
bottom: 0px;
}

View File

@ -10,32 +10,12 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: CComponentBox.class:213
msgid "Experimental"
#: .project:1
msgid "Gambas 3"
msgstr ""
#: CComponentBox.class:215 FPropertyComponent.class:325
msgid "Not finished but stable"
msgstr ""
#: CComponentBox.class:223 ProjectItem.class:68
msgid "Authors"
msgstr ""
#: CComponentBox.class:230 FPropertyComponent.class:358
msgid "Requires"
msgstr ""
#: CComponentBox.class:232
msgid "Excludes"
msgstr ""
#: CComponentBox.class:238
msgid "Implements"
msgstr ""
#: CComponentBox.class:251 LibraryItem.class:58
msgid "Provides"
#: .project:2
msgid "Integrated Development Environment for Gambas"
msgstr ""
#: CComponent.class:79
@ -282,6 +262,34 @@ msgstr ""
msgid "Loading information on component &1..."
msgstr ""
#: CComponentBox.class:213
msgid "Experimental"
msgstr ""
#: CComponentBox.class:215 FPropertyComponent.class:325
msgid "Not finished but stable"
msgstr ""
#: CComponentBox.class:223 ProjectItem.class:68
msgid "Authors"
msgstr ""
#: CComponentBox.class:230 FPropertyComponent.class:358
msgid "Requires"
msgstr ""
#: CComponentBox.class:232
msgid "Excludes"
msgstr ""
#: CComponentBox.class:238
msgid "Implements"
msgstr ""
#: CComponentBox.class:251 LibraryItem.class:58
msgid "Provides"
msgstr ""
#: CInsertColor.class:103 FEditor.class:3648 FTextEditor.class:1011
msgid "Insert color"
msgstr ""
@ -458,18 +466,18 @@ msgstr ""
#: FColorChooser.class:216 FCommit.class:386 FConflict.class:191
#: FConnectionEditor.class:284 FCreateFile.class:938 FDebugInfo.class:520
#: FEditor.class:2274 FFindList.class:195 FFontChooser.class:85
#: FForm.class:2960 FGotoLine.class:63 FHelpBrowser.class:341
#: FIconEditor.class:1413 FImportTable.class:39 FList.class:155
#: FMain.class:200 FMakeInstall.class:326 FMenu.class:1235
#: FNewConnection.class:317 FNewTable.class:165 FNewTranslation.class:70
#: FOpenProject.class:533 FOption.class:613 FPasteSpecial.class:279
#: FPasteTable.class:337 FPropertyComponent.class:473
#: FPropertyProject.class:801 FReportBorderChooser.class:345
#: FReportBrushChooser.class:475 FReportCoordChooser.class:126 FSave.class:118
#: FSaveProjectAs.class:130 FSelectExtraFile.class:78 FSelectIcon.class:272
#: FSnippet.class:142 FTableChooser.class:144 FTextEditor.class:475
#: FText.class:106 FTranslate.class:638 Project.module:412
#: FEditor.class:2274 FFontChooser.class:85 FForm.class:2960
#: FGotoLine.class:63 FHelpBrowser.class:341 FIconEditor.class:1413
#: FImportTable.class:39 FList.class:155 FMain.class:200
#: FMakeInstall.class:326 FMenu.class:1235 FNewConnection.class:317
#: FNewTable.class:165 FNewTranslation.class:70 FOpenProject.class:533
#: FOption.class:613 FPasteSpecial.class:279 FPasteTable.class:337
#: FPropertyComponent.class:473 FPropertyProject.class:801
#: FReportBorderChooser.class:345 FReportBrushChooser.class:475
#: FReportCoordChooser.class:126 FSave.class:118 FSaveProjectAs.class:130
#: FSelectExtraFile.class:78 FSelectIcon.class:272 FSnippet.class:142
#: FTableChooser.class:144 FText.class:106 FTextEditor.class:475
#: FTranslate.class:638 Project.module:412
msgid "Cancel"
msgstr ""
@ -584,9 +592,9 @@ msgstr ""
msgid "&Edit"
msgstr ""
#: FConflict.class:25 FFindList.class:203 FIconEditor.class:1426
#: FImportTable.class:701 FMakeInstall.class:275 FSearch.class:1182
#: FSystemInfo.class:73 FTips.class:240
#: FConflict.class:25 FIconEditor.class:1426 FImportTable.class:701
#: FMakeInstall.class:275 FSearch.class:1182 FSystemInfo.class:73
#: FTips.class:240
msgid "Close"
msgstr ""
@ -623,7 +631,6 @@ msgid "Conflict files"
msgstr ""
#: FConflict.class:384 FCreateFile.class:736 FDebugInfo.class:63
#: FFindList.class:76
msgid "Text"
msgstr ""
@ -938,7 +945,7 @@ msgstr ""
msgid "Module"
msgstr ""
#: FCreateFile.class:631 FDebugInfo.class:49 FFindList.class:71 FInfo.class:85
#: FCreateFile.class:631 FDebugInfo.class:49 FInfo.class:85
msgid "Class"
msgstr ""
@ -1154,8 +1161,8 @@ msgstr ""
msgid "Function"
msgstr ""
#: FDebugInfo.class:51 FFindList.class:73 FIconEditor.class:2273
#: FImportTable.class:76 FOption.class:1188
#: FDebugInfo.class:51 FIconEditor.class:2273 FImportTable.class:76
#: FOption.class:1188
msgid "Line"
msgstr ""
@ -1273,8 +1280,7 @@ msgstr ""
msgid "Show search window"
msgstr ""
#: FDebugInfo.class:1397 FFindList.class:279 FSearch.class:432
#: FTranslate.class:599
#: FDebugInfo.class:1397 FSearch.class:432 FTranslate.class:599
msgid "Search string cannot be found."
msgstr ""
@ -1405,14 +1411,6 @@ msgstr ""
msgid "Procedure list"
msgstr ""
#: FFindList.class:75
msgid "Column"
msgstr ""
#: FFindList.class:244
msgid "Find list"
msgstr ""
#: FFontChooser.class:57
msgid "Select a font"
msgstr ""
@ -3339,42 +3337,6 @@ msgstr ""
msgid "Also copy table &data"
msgstr ""
#: FPropertyComponent.class:149
msgid "Cannot write component description file."
msgstr ""
#: FPropertyComponent.class:318
msgid "Component advancement"
msgstr ""
#: FPropertyComponent.class:325
msgid "Finished and stable"
msgstr ""
#: FPropertyComponent.class:325
msgid "Beta version"
msgstr ""
#: FPropertyComponent.class:336
msgid "This component is hidden"
msgstr ""
#: FPropertyComponent.class:349
msgid "Exported classes"
msgstr ""
#: FPropertyComponent.class:363
msgid "Features"
msgstr ""
#: FPropertyComponent.class:404 FPropertyProject.class:1639
msgid "Components"
msgstr ""
#: FPropertyComponent.class:448
msgid "Remove All"
msgstr ""
#: FProperty.class:353
msgid "Forbidden characters in control name."
msgstr ""
@ -3430,6 +3392,42 @@ msgstr ""
msgid "..."
msgstr ""
#: FPropertyComponent.class:149
msgid "Cannot write component description file."
msgstr ""
#: FPropertyComponent.class:318
msgid "Component advancement"
msgstr ""
#: FPropertyComponent.class:325
msgid "Finished and stable"
msgstr ""
#: FPropertyComponent.class:325
msgid "Beta version"
msgstr ""
#: FPropertyComponent.class:336
msgid "This component is hidden"
msgstr ""
#: FPropertyComponent.class:349
msgid "Exported classes"
msgstr ""
#: FPropertyComponent.class:363
msgid "Features"
msgstr ""
#: FPropertyComponent.class:404 FPropertyProject.class:1639
msgid "Components"
msgstr ""
#: FPropertyComponent.class:448
msgid "Remove All"
msgstr ""
#: FPropertyProject.class:106
msgid "Not translatable"
msgstr ""
@ -3814,6 +3812,14 @@ msgstr ""
msgid "Connection"
msgstr ""
#: FText.class:77
msgid "Edit text property"
msgstr ""
#: FText.class:95
msgid "Use a fixed font"
msgstr ""
#: FTextEditor.class:670
msgid "The file has been compressed from &1 to &2 bytes (&3)."
msgstr ""
@ -3834,14 +3840,6 @@ msgstr ""
msgid "Uncompress file"
msgstr ""
#: FText.class:77
msgid "Edit text property"
msgstr ""
#: FText.class:95
msgid "Use a fixed font"
msgstr ""
#: FTips.class:47
msgid "Tip of the day"
msgstr ""
@ -5292,18 +5290,6 @@ msgstr ""
msgid "'tar' has returned the following error code:"
msgstr ""
#: ProjectItem.class:68
msgid "Author"
msgstr ""
#: .project:1
msgid "Gambas 3"
msgstr ""
#: .project:2
msgid "Integrated Development Environment for Gambas"
msgstr ""
#: Project.module:181
msgid "Automation"
msgstr ""
@ -5613,6 +5599,10 @@ msgstr ""
msgid "Unable to convert &1"
msgstr ""
#: ProjectItem.class:68
msgid "Author"
msgstr ""
#: Save.module:39
msgid "Cannot save file !"
msgstr ""

View File

@ -444,8 +444,8 @@ Private Sub AddEmblem(hSource As Image, sEmblem As String) As Image
hEmblem = Picture[sEmblem].Image.Stretch(iSize * 1.5, iSize * 1.5)
hImage = New Image(hSource.Width + iSize, hSource.Height, Color.Transparent)
hImage.Draw(hSource, iSize, 0)
hImage.Draw(hEmblem, 0, (hImage.H - hEmblem.H) / 2)
hImage.PaintImage(hSource, iSize, 0)
hImage.PaintImage(hEmblem, 0, (hImage.H - hEmblem.H) / 2)
Return hImage
End
@ -454,8 +454,8 @@ Private Sub AddLinkEmblem(hSource As Image) As Image
Dim hImage As New Image(hSource.Width + 1, hSource.Height + 1, Color.Transparent)
hImage.Draw(hSource, 1, 0)
hImage.Draw(Picture["img/16/link.png"].Image, 0, hImage.Height - 16)
hImage.PaintImage(hSource, 1, 0)
hImage.PaintImage(Picture["img/16/link.png"].Image, 0, hImage.Height - 16)
Return hImage
End

View File

@ -295,7 +295,7 @@ Public Sub dwgPaste_Draw()
Dim CP As Integer
Dim W As Integer
Dim hTemp As Image
Dim XD,WD As Integer
Dim XD, WD As Integer
If Not $hPaste Then Return
@ -333,7 +333,7 @@ Public Sub dwgPaste_Draw()
If $bTrans Then
hTemp = $hImage.Copy($XS, $YS, $hPaste.Width, $hPaste.Height)
hTemp.Draw($hPaste, 0, 0)
hTemp.PaintImage($hPaste, 0, 0)
'Draw.Zoom($hImage, $iScale, SX * $iScale, SY * $iScale, SX + $XS, SY + $YS, DX - SX + 1, DY - SY + 1)
Draw.Zoom(hTemp, $iScale, SX * $iScale, SY * $iScale, SX, SY, DX - SX + 1, DY - SY + 1)

View File

@ -266,7 +266,7 @@ Public Sub DrawIcon(hCont As Container, hCCtrl As CControl, sImage As String)
hPict = Picture["$arr-" & sImage]
If Not hPict Then
hImage = New Image(ICON_SIZE, ICON_SIZE, Color.RGB(0, 0, 0, 96))
hImage.Draw(Image.Load("img/family" &/ sImage & ".png"), 0, 0)
hImage.PaintImage(Image.Load("img/family" &/ sImage & ".png"), 0, 0)
hPict = hImage.Picture
Picture["$arr-" & sImage] = hPict
Endif

View File

@ -700,8 +700,8 @@ Private Sub AddEmblem(hSource As Image, sEmblem As String) As Image
hEmblem = Picture[sEmblem].Image.Stretch(iSize * 1.5, iSize * 1.5)
hImage = New Image(hSource.Width + iSize, hSource.Height, Color.Transparent)
hImage.Draw(hSource, iSize, 0)
hImage.Draw(hEmblem, 0, (hImage.H - hEmblem.H) / 2)
hImage.PaintImage(hSource, iSize, 0)
hImage.PaintImage(hEmblem, 0, (hImage.H - hEmblem.H) / 2)
Return hImage
End
@ -710,8 +710,8 @@ Private Sub AddLinkEmblem(hSource As Image) As Image
Dim hImage As New Image(hSource.Width + 1, hSource.Height + 1, Color.Transparent)
hImage.Draw(hSource, 1, 0)
hImage.Draw(Picture["img/16/link.png"].Image, 0, hImage.Height - 16)
hImage.PaintImage(hSource, 1, 0)
hImage.PaintImage(Picture["img/16/link.png"].Image, 0, hImage.Height - 16)
Return hImage
End
@ -732,7 +732,7 @@ Public Sub MakeModuleIcon(sModule As String, Optional iSize As Integer) As Image
hImage = $cImageCache["base"]
hImage = hImage.Stretch(iSize, iSize)
hImageModule = Image.Load("img/module" &/ sModule & ".png") '.Stretch(iSize / 2, iSize / 2)
hImage.Draw(hImageModule, iSize / 4, iSize / 4, iSize / 2, iSize / 2)
hImage.PaintImage(hImageModule, iSize / 4, iSize / 4, iSize / 2, iSize / 2)
$cImageCache[sKey] = hImage
Endif
@ -4444,7 +4444,7 @@ Public Function StretchIcon(sPath As String, Optional iSize As Integer = 48) As
If W < iSize Or H < iSize Then
hBackground = New Image(iSize, iSize)
hBackground.Fill(Color.Transparent)
hBackground.Draw(hImage, (iSize - W) / 2, (iSize - H) / 2, W, H)
hBackground.PaintImage(hImage, (iSize - W) / 2, (iSize - H) / 2, W, H)
hImage = hBackground
Else
hImage = hImage.Stretch(W, H)
@ -4849,7 +4849,7 @@ Public Sub MakeDirectoryIcon(Optional sDir As String)
If sIcon Then
Try hIcon = StretchIcon(sIcon, 16)
If hIcon Then hDirIcon.Draw(hIcon, 40, 34)
If hIcon Then hDirIcon.PaintImage(hIcon, 40, 34)
Endif
hDirIcon.Save(sDir &/ ".icon.png")

View File

@ -139,7 +139,7 @@ BEGIN_METHOD_VOID(CIMAGE_free)
END_METHOD
#endif
BEGIN_PROPERTY(CIMAGE_picture)
BEGIN_PROPERTY(Image_Picture)
check_image(THIS);
@ -152,7 +152,7 @@ BEGIN_PROPERTY(CIMAGE_picture)
END_PROPERTY
BEGIN_METHOD(CIMAGE_load, GB_STRING path)
BEGIN_METHOD(Image_Load, GB_STRING path)
CIMAGE *image;
char *addr;
@ -177,7 +177,7 @@ BEGIN_METHOD(CIMAGE_load, GB_STRING path)
END_METHOD
BEGIN_METHOD(CIMAGE_save, GB_STRING path; GB_INTEGER quality)
BEGIN_METHOD(Image_Save, GB_STRING path; GB_INTEGER quality)
check_image(THIS);
@ -191,7 +191,7 @@ BEGIN_METHOD(CIMAGE_save, GB_STRING path; GB_INTEGER quality)
END_METHOD
BEGIN_METHOD(CIMAGE_stretch, GB_INTEGER width; GB_INTEGER height)
BEGIN_METHOD(Image_Stretch, GB_INTEGER width; GB_INTEGER height)
CIMAGE *img;
@ -202,7 +202,7 @@ BEGIN_METHOD(CIMAGE_stretch, GB_INTEGER width; GB_INTEGER height)
END_METHOD
BEGIN_METHOD(CIMAGE_rotate, GB_FLOAT angle)
BEGIN_METHOD(Image_Rotate, GB_FLOAT angle)
CIMAGE *img;
@ -213,7 +213,7 @@ BEGIN_METHOD(CIMAGE_rotate, GB_FLOAT angle)
END_METHOD
BEGIN_METHOD(CIMAGE_draw, GB_OBJECT img; GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h; GB_INTEGER sx; GB_INTEGER sy; GB_INTEGER sw; GB_INTEGER sh)
BEGIN_METHOD(Image_PaintImage, GB_OBJECT img; GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h; GB_INTEGER sx; GB_INTEGER sy; GB_INTEGER sw; GB_INTEGER sh)
int x, y, w, h, sx, sy, sw, sh;
CIMAGE *image = (CIMAGE *)VARG(img);
@ -246,15 +246,15 @@ GB_DESC CImageDesc[] =
{
GB_DECLARE("Image", sizeof(CIMAGE)),
GB_STATIC_METHOD("Load", "Image", CIMAGE_load, "(Path)s"),
GB_METHOD("Save", 0, CIMAGE_save, "(Path)s[(Quality)i]"),
GB_STATIC_METHOD("Load", "Image", Image_Load, "(Path)s"),
GB_METHOD("Save", 0, Image_Save, "(Path)s[(Quality)i]"),
GB_METHOD("Stretch", "Image", CIMAGE_stretch, "(Width)i(Height)i"),
GB_METHOD("Rotate", "Image", CIMAGE_rotate, "(Angle)f"),
GB_METHOD("Stretch", "Image", Image_Stretch, "(Width)i(Height)i"),
GB_METHOD("Rotate", "Image", Image_Rotate, "(Angle)f"),
GB_METHOD("Draw", 0, CIMAGE_draw, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_METHOD("PaintImage", 0, Image_PaintImage, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_PROPERTY_READ("Picture", "Picture", CIMAGE_picture),
GB_PROPERTY_READ("Picture", "Picture", Image_Picture),
GB_INTERFACE("Paint", &PAINT_Interface),

View File

@ -897,6 +897,14 @@ gPicture *gPicture::stretch(int w, int h, bool smooth)
GdkPixbuf *image;
int ws, hs;
if (w <= 0 && h <= 0)
return new gPicture();
if (w < 0)
w = width() * h / height();
else if (h < 0)
h = height() * w / width();
if (w <= 0 || h <= 0)
return new gPicture();

View File

@ -211,7 +211,7 @@ BEGIN_METHOD(Image_Sharpen, GB_INTEGER radius)
END_METHOD
BEGIN_METHOD(Image_Draw, GB_OBJECT img; GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h; GB_INTEGER sx; GB_INTEGER sy; GB_INTEGER sw; GB_INTEGER sh)
BEGIN_METHOD(Image_PaintImage, GB_OBJECT img; GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h; GB_INTEGER sx; GB_INTEGER sy; GB_INTEGER sw; GB_INTEGER sh)
int x, y, w, h, sx, sy, sw, sh, src_w, src_h;
CIMAGE *image = (CIMAGE *)VARG(img);
@ -270,7 +270,7 @@ GB_DESC ImageDesc[] =
GB_METHOD("Sharpen", "Image", Image_Sharpen, "[(Radius)i]"),
GB_METHOD("Tile", "Image", Image_Tile, NULL),
GB_METHOD("Draw", NULL, Image_Draw, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_METHOD("PaintImage", NULL, Image_PaintImage, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_METHOD("Scroll", NULL, Image_Scroll, "(DX)i(DY)i[(X)i(Y)i(Width)i(Height)i]"),
//Gb_INTERFACE("Draw", &DRAW_Interface),

View File

@ -1,22 +1,22 @@
/***************************************************************************
CImage.cpp
CImage.cpp
(c) 2000-2011 Benoît Minisini <gambas@users.sourceforge.net>
(c) 2000-2011 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
@ -49,32 +49,32 @@
const char *CIMAGE_get_format(QString path)
{
int pos;
int pos;
pos = path.lastIndexOf('.');
if (pos < 0)
return NULL;
pos = path.lastIndexOf('.');
if (pos < 0)
return NULL;
path = path.mid(pos + 1).toLower();
path = path.mid(pos + 1).toLower();
if (path == "png")
return "PNG";
else if (path == "jpg" || path == "jpeg")
return "JPEG";
else if (path == "gif")
return "GIF";
else if (path == "bmp")
return "BMP";
else if (path == "xpm")
return "XPM";
else
return NULL;
if (path == "png")
return "PNG";
else if (path == "jpg" || path == "jpeg")
return "JPEG";
else if (path == "gif")
return "GIF";
else if (path == "bmp")
return "BMP";
else if (path == "xpm")
return "XPM";
else
return NULL;
}
/*******************************************************************************
Image
Image
*******************************************************************************/
@ -99,7 +99,7 @@ static GB_IMG_OWNER _image_owner = {
"gb.qt4",
GB_IMAGE_BGRA,
free_image,
free_image,
free_image,
temp_image,
NULL,
};
@ -125,149 +125,133 @@ static void take_image(CIMAGE *_object, QImage *image)
CIMAGE *CIMAGE_create(QImage *image)
{
CIMAGE *img;
static GB_CLASS class_id = NULL;
static GB_CLASS class_id = NULL;
if (!class_id)
class_id = GB.FindClass("Image");
if (!class_id)
class_id = GB.FindClass("Image");
GB.New(POINTER(&img), class_id, NULL, NULL);
if (image)
GB.New(POINTER(&img), class_id, NULL, NULL);
if (image)
{
if (!image->isNull() && image->format() != QImage::Format_ARGB32)
*image = image->convertToFormat(QImage::Format_ARGB32);
take_image(img, image);
take_image(img, image);
}
else
take_image(img, new QImage());
take_image(img, new QImage());
return img;
return img;
}
BEGIN_PROPERTY(CIMAGE_picture)
BEGIN_PROPERTY(IMAGE_Picture)
CPICTURE *pict;
check_image(THIS);
CPICTURE *pict;
check_image(THIS);
GB.New(POINTER(&pict), GB.FindClass("Picture"), NULL, NULL);
if (!QIMAGE->isNull())
*pict->pixmap = QPixmap::fromImage(*QIMAGE);
GB.New(POINTER(&pict), GB.FindClass("Picture"), NULL, NULL);
if (!QIMAGE->isNull())
*pict->pixmap = QPixmap::fromImage(*QIMAGE);
GB.ReturnObject(pict);
GB.ReturnObject(pict);
END_PROPERTY
#if 0
BEGIN_METHOD(CIMAGE_resize, GB_INTEGER width; GB_INTEGER height)
check_image(THIS);
if (QIMAGE->isNull())
{
take_image(THIS, new QImage(VARG(width), VARG(height), QImage::Format_ARGB32));
}
else
{
take_image(THIS, new QImage(QIMAGE->copy(0, 0, VARG(width), VARG(height))));
}
END_METHOD
#endif
BEGIN_METHOD(CIMAGE_load, GB_STRING path)
QImage *p;
CIMAGE *img;
if (CPICTURE_load_image(&p, STRING(path), LENGTH(path)))
{
p->convertToFormat(QImage::Format_ARGB32);
img = CIMAGE_create(p);
GB.ReturnObject(img);
}
else
GB.Error("Unable to load image");
END_METHOD
BEGIN_METHOD(CIMAGE_save, GB_STRING path; GB_INTEGER quality)
QString path = TO_QSTRING(GB.FileName(STRING(path), LENGTH(path)));
bool ok = false;
const char *fmt = CIMAGE_get_format(path);
if (!fmt)
{
GB.Error("Unknown format");
return;
}
check_image(THIS);
ok = QIMAGE->save(path, fmt, VARGOPT(quality, -1));
if (!ok)
GB.Error("Unable to save picture");
END_METHOD
BEGIN_METHOD(CIMAGE_stretch, GB_INTEGER width; GB_INTEGER height)
//static int count = 0;
QImage *stretch;
check_image(THIS);
check_image(THIS);
if (QIMAGE->isNull())
{
stretch = new QImage(VARG(width), VARG(height), QImage::Format_ARGB32);
take_image(THIS, new QImage(VARG(width), VARG(height), QImage::Format_ARGB32));
}
else
{
stretch = new QImage();
*stretch = QIMAGE->scaled(VARG(width), VARG(height), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
stretch->detach();
take_image(THIS, new QImage(QIMAGE->copy(0, 0, VARG(width), VARG(height))));
}
GB.ReturnObject(CIMAGE_create(stretch));
END_METHOD
#if 0
BEGIN_METHOD_VOID(CIMAGE_flip)
QImage *mirror = new QImage();
check_image(THIS);
*mirror = QIMAGE->mirrored(true, false);
GB.ReturnObject(CIMAGE_create(mirror));
END_METHOD
#endif
#if 0
BEGIN_METHOD_VOID(CIMAGE_mirror)
BEGIN_METHOD(IMAGE_Load, GB_STRING path)
QImage *mirror = new QImage();
check_image(THIS);
*mirror = QIMAGE->mirrored(false, true);
GB.ReturnObject(CIMAGE_create(mirror));
QImage *p;
CIMAGE *img;
if (CPICTURE_load_image(&p, STRING(path), LENGTH(path)))
{
p->convertToFormat(QImage::Format_ARGB32);
img = CIMAGE_create(p);
GB.ReturnObject(img);
}
else
GB.Error("Unable to load image");
END_METHOD
#endif
BEGIN_METHOD(CIMAGE_rotate, GB_FLOAT angle)
QImage *rotate = new QImage();
BEGIN_METHOD(IMAGE_Save, GB_STRING path; GB_INTEGER quality)
QString path = TO_QSTRING(GB.FileName(STRING(path), LENGTH(path)));
bool ok = false;
const char *fmt = CIMAGE_get_format(path);
if (!fmt)
{
GB.Error("Unknown format");
return;
}
check_image(THIS);
ok = QIMAGE->save(path, fmt, VARGOPT(quality, -1));
if (!ok)
GB.Error("Unable to save picture");
END_METHOD
BEGIN_METHOD(IMAGE_Stretch, GB_INTEGER width; GB_INTEGER height)
//static int count = 0;
QImage *stretch;
int w, h;
check_image(THIS);
stretch = new QImage();
if (!QIMAGE->isNull())
{
w = VARG(width);
h = VARG(height);
if (w < 0 && h > 0)
w = QIMAGE->width() * h / QIMAGE->height();
else if (h < 0 && w > 0)
h = QIMAGE->height() * w / QIMAGE->width();
if (w > 0 && h > 0)
{
*stretch = QIMAGE->scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
stretch->detach();
}
}
GB.ReturnObject(CIMAGE_create(stretch));
END_METHOD
BEGIN_METHOD(IMAGE_Rotate, GB_FLOAT angle)
QImage *rotate = new QImage();
double angle = VARG(angle);
check_image(THIS);
check_image(THIS);
if (angle != 0.0)
{
QMatrix mat;
@ -282,30 +266,30 @@ BEGIN_METHOD(CIMAGE_rotate, GB_FLOAT angle)
END_METHOD
BEGIN_METHOD(CIMAGE_draw, GB_OBJECT img; GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h; GB_INTEGER sx; GB_INTEGER sy; GB_INTEGER sw; GB_INTEGER sh)
BEGIN_METHOD(IMAGE_PaintImage, GB_OBJECT img; GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h; GB_INTEGER sx; GB_INTEGER sy; GB_INTEGER sw; GB_INTEGER sh)
int x, y, w, h, sx, sy, sw, sh;
CIMAGE *image = (CIMAGE *)VARG(img);
QImage *src, *dst;
double scale_x, scale_y;
int x, y, w, h, sx, sy, sw, sh;
CIMAGE *image = (CIMAGE *)VARG(img);
QImage *src, *dst;
double scale_x, scale_y;
if (GB.CheckObject(image))
return;
if (GB.CheckObject(image))
return;
src = check_image(image);
dst = check_image(THIS);
x = VARGOPT(x, 0);
y = VARGOPT(y, 0);
w = VARGOPT(w, -1);
h = VARGOPT(h, -1);
x = VARGOPT(x, 0);
y = VARGOPT(y, 0);
w = VARGOPT(w, -1);
h = VARGOPT(h, -1);
sx = VARGOPT(sx, 0);
sy = VARGOPT(sy, 0);
sw = VARGOPT(sw, src->width());
sh = VARGOPT(sh, src->height());
sx = VARGOPT(sx, 0);
sy = VARGOPT(sy, 0);
sw = VARGOPT(sw, src->width());
sh = VARGOPT(sh, src->height());
DRAW_NORMALIZE(x, y, w, h, sx, sy, sw, sh, src->width(), src->height());
DRAW_NORMALIZE(x, y, w, h, sx, sy, sw, sh, src->width(), src->height());
if (w != sw || h != sh)
{
@ -335,19 +319,20 @@ END_METHOD
GB_DESC CImageDesc[] =
{
GB_DECLARE("Image", sizeof(CIMAGE)),
GB_DECLARE("Image", sizeof(CIMAGE)),
GB_STATIC_METHOD("Load", "Image", CIMAGE_load, "(Path)s"),
GB_METHOD("Save", NULL, CIMAGE_save, "(Path)s[(Quality)i]"),
GB_STATIC_METHOD("Load", "Image", IMAGE_Load, "(Path)s"),
GB_METHOD("Save", NULL, IMAGE_Save, "(Path)s[(Quality)i]"),
GB_METHOD("Stretch", "Image", CIMAGE_stretch, "(Width)i(Height)i"),
GB_METHOD("Rotate", "Image", CIMAGE_rotate, "(Angle)f"),
GB_METHOD("Stretch", "Image", IMAGE_Stretch, "(Width)i(Height)i"),
GB_METHOD("Rotate", "Image", IMAGE_Rotate, "(Angle)f"),
GB_METHOD("Draw", NULL, CIMAGE_draw, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_METHOD("PaintImage", NULL, IMAGE_PaintImage, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_PROPERTY_READ("Picture", "Picture", CIMAGE_picture),
GB_PROPERTY_READ("Picture", "Picture", IMAGE_Picture),
GB_INTERFACE("Paint", &PAINT_Interface),
GB_END_DECLARE
GB_END_DECLARE
};

View File

@ -253,6 +253,18 @@ BEGIN_METHOD(Image_DrawAlpha, GB_OBJECT image; GB_INTEGER x; GB_INTEGER y; GB_IN
END_METHOD
BEGIN_METHOD(Image_DrawImage, GB_OBJECT image; GB_INTEGER x; GB_INTEGER y; GB_INTEGER srcx; GB_INTEGER srcy; GB_INTEGER srcw; GB_INTEGER srch)
CIMAGE *image = VARG(image);
if (GB.CheckObject(image))
return;
IMAGE_bitblt(THIS_IMAGE, VARGOPT(x, 0), VARGOPT(y, 0), &image->image, VARGOPT(srcx, 0), VARGOPT(srcy, 0), VARGOPT(srcw, -1), VARGOPT(srch, -1));
GB.ReturnObject(THIS);
END_METHOD
BEGIN_PROPERTY(Image_Format)
char *format;
@ -325,7 +337,7 @@ GB_DESC CImageDesc[] =
GB_METHOD("DrawAlpha", "Image", Image_DrawAlpha, "(Image)Image;[(X)i(Y)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
//GB_METHOD("Transform", "Image", CIMAGE_transform, "(SrcX)f(SrcY)f(DepX)f(DepY)f"),
//GB_METHOD("Draw", NULL, CIMAGE_draw, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_METHOD("DrawImage", "Image", Image_DrawImage, "(Image)Image;(X)i(Y)i[(Width)i(Height)i(SrcX)i(SrcY)i(SrcWidth)i(SrcHeight)i]"),
GB_END_DECLARE
};

View File

@ -838,9 +838,12 @@ int IMAGE_get_default_format()
void IMAGE_bitblt(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int sw, int sh)
{
if (dst->format != src->format)
int sfmt = src->format;
int dfmt = dst->format;
if (!GB_IMAGE_FMT_IS_32_BITS(sfmt) || !GB_IMAGE_FMT_IS_32_BITS(dfmt))
{
GB.Error("The source image and the destination image must have the same format");
GB.Error("The pixel format of both images must be 32 bits");
return;
}
@ -861,40 +864,55 @@ void IMAGE_bitblt(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int
SYNCHRONIZE(src);
SYNCHRONIZE(dst);
if (GB_IMAGE_FMT_IS_32_BITS(src->format))
uint *d = (uint *)dst->data + dy * dst->width + dx;
uint *s = (uint *)src->data + sy * src->width + sx;
if (sfmt != dfmt)
{
uint *d = (uint *)dst->data + dy * dst->width + dx;
uint *s = (uint *)src->data + sy * src->width + sx;
if (sw < 64)
const int dd = dst->width - sw;
const int ds = src->width - sw;
int t;
while (sh--)
{
// Trust ourselves
const int dd = dst->width - sw;
const int ds = src->width - sw;
int t;
while (sh--)
for (t = sw; t--;)
{
for (t = sw; t--;)
*d++ = *s++;
d += dd;
s += ds;
}
}
else
{
// Trust libc
const int dd = dst->width;
const int ds = src->width;
const int b = sw * sizeof(uint);
while (sh--)
{
memcpy(d, s, b);
d += dd;
s += ds;
*d = BGRA_to_format(BGRA_from_format(*s, sfmt), dfmt);
d++;
s++;
}
d += dd;
s += ds;
}
}
else // 24 bits
else if (sw < 64)
{
const int dd = dst->width - sw;
const int ds = src->width - sw;
int t;
while (sh--)
{
for (t = sw; t--;)
*d++ = *s++;
d += dd;
s += ds;
}
}
else
{
// Trust libc
const int dd = dst->width;
const int ds = src->width;
const int b = sw * sizeof(uint);
while (sh--)
{
memcpy(d, s, b);
d += dd;
s += ds;
}
}
/*else if (GB_IMAGE_FMT_IS_24_BITS(sfmt) && GB_IMAGE_FMT_IS_24_BITS(sfmt))
{
char *d = (char *)dst->data + (dy * dst->width + dx) * 3;
char *s = (char *)src->data + (sy * src->width + sx) * 3;
@ -908,19 +926,13 @@ void IMAGE_bitblt(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int
d += dd;
s += ds;
}
}
}*/
MODIFY(dst);
}
void IMAGE_draw_alpha(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int sw, int sh)
{
/*if (dst->format != src->format)
{
GB.Error("The source image and the destination image must have the same format");
return;
}*/
if (!GB_IMAGE_FMT_IS_32_BITS(src->format) || !GB_IMAGE_FMT_IS_32_BITS(dst->format))
{
GB.Error("The images must have an alpha channel");
@ -991,8 +1003,6 @@ void IMAGE_draw_alpha(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy,
{
for (t = sw; t--; d += 4,s += 4)
{
//cs = BGRA_from_format(*s, sformat);
//cd = BGRA_from_format(*d, dformat);
if (*s < *d)
*d = *s;
}