Re: Rotate Picture

2019-06-23 Thread Keisuke Miyako via 4D_Tech
I think not.

a DOM reference is independent from the 4D picture,
except for ones that are embedded (exported with the "Own" option).

then, a 4D text (the local variable) that contains the hex. representation of 
the reference
is not in any way associated with the DOM reference, or the picture for that 
matter,
unlike collection or object, so it does not matter that the scope of the 
variable is local.

it is absolutely your responsibility to keep track of these (old) kinds of 
references.

2019/06/24 2:04、Keith Culotta via 4D_Tech 
<4d_tech@lists.4d.com>のメール:

Not that it is good form to rely on this, but does a SVG document referenced in 
a local variable get cleared when the method in which it was created terminates?



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture

2019-06-23 Thread Keith Culotta via 4D_Tech
Not that it is good form to rely on this, but does a SVG document referenced in 
a local variable get cleared when the method in which it was created terminates?

Thanks,
Keith - CDI

> On Jun 22, 2019, at 9:01 PM, Keisuke Miyako via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> I think the default export option is "copy"
> 
> if you don't SVG_CLEAR (see Cannon's code) you'd be leaking memory.
> 

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture

2019-06-22 Thread Keisuke Miyako via 4D_Tech
I think the default export option is "copy"

if you don't SVG_CLEAR (see Cannon's code) you'd be leaking memory.

I suppose you could save speed with the "own" option (you won't need to CLEAR 
any more)

but the difference is probably negligible.

2019/06/23 9:28、JOHN BAUGHMAN via 4D_Tech 
<4d_tech@lists.4d.com>のメール:
$MyPicture:=SVG_Export_to_picture ($SVGRef)  //The image is correctly rotated 
but is now in a square picture



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture

2019-06-22 Thread Cannon Smith via 4D_Tech
For all I remember you gave it to me! :-)

Glad it works.

--
Cannon.Smith
Synergy Farm Solutions Inc.
Aetna, AB Canada




> On Jun 22, 2019, at 6:28 PM, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Your code looked vaguely familiar to me. I had not thought to look and see if 
> I already had a method to rotate pictures. Sure enough I do. Looks very 
> similar to yours, even uses the same  variable conventions. Perhaps you gave 
> this to me back in 2011?
> 
> In any event thanks. I am going to use your method as it is a bit more 
> compact than mine. Mine is a tad faster, however. I posted mine below for 
> comparison.

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture

2019-06-22 Thread JOHN BAUGHMAN via 4D_Tech
Thanks Cannon.

Your code looked vaguely familiar to me. I had not thought to look and see if I 
already had a method to rotate pictures. Sure enough I do. Looks very similar 
to yours, even uses the same  variable conventions. Perhaps you gave this to me 
back in 2011?

In any event thanks. I am going to use your method as it is a bit more compact 
than mine. Mine is a tad faster, however. I posted mine below for comparison.

John


——]
C_PICTURE($1;$MyPicture)
C_LONGINT($2;$rotation)
  // 
$error:=SVG_Set_error_handler ("SVG_error_mgmt")
$MyPicture:=$1
$rotation:=$2
$temporaryPictureFilePath:=Temporary folder+"tempPicture.jpg"
WRITE PICTURE FILE($temporaryPictureFilePath;$MyPicture)  //write the 
picture to file so we can get it with a URL

PICTURE PROPERTIES($MyPicture;$width;$height)

If ($width>=$height)  //get the largest dimension of the picture
$svgAreaSize:=$width
Else 
$svgAreaSize:=$height
End if 

$SVGRef:=SVG_New ($svgAreaSize;$svgAreaSize)  //make the new SVG area 
big enough to hold the picture rotated

If ($width>=$height)  //center the picture in the SVG area 
$picRef:=SVG_New_image 
($SVGRef;"file://"+$temporaryPictureFilePath;0;($width/2)-($height/2);$width;$height)
Else 
$picRef:=SVG_New_image 
($SVGRef;"file://"+$temporaryPictureFilePath;($height/2)-($width/2);0;$width;$height)
End if 

SVG_SET_TRANSFORM_ROTATE 
($picRef;$rotation;$svgAreaSize/2;$svgAreaSize/2)  //rotate it

$MyPicture:=SVG_Export_to_picture ($SVGRef)  //The image is correctly 
rotated but is now in a square picture

Case of   //crop the picture back down to the size of the image if the 
image is not square
: ($width>$height)
TRANSFORM 
PICTURE($MyPicture;Crop;($width/2)-($height/2);0;$height;$svgAreaSize)
: ($height>$width)
TRANSFORM 
PICTURE($MyPicture;Crop;0;($height/2)-($width/2);$svgAreaSize;$width)
End case 

$0:=$MyPicture

 

> On Jun 22, 2019, at 11:37 AM, Cannon Smith via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Hi John,
> 
> Here is the code from a method I use called Photo_Rotate:
> 
>  //This method rotates a picture. While it will rotate the picture to
>  //any angle, this method is really expecting it to rotate 90˚, 180˚,
>  //or 270˚.
> 
> C_PICTURE($1;$gPicture)
> C_REAL($2;$rDegrees)  //Expects 90, 180, or 270
> C_PICTURE($0)
> 
> $gPicture:=$1
> $rDegrees:=$2
> 
> C_LONGINT($lWidth;$lHeight)
> C_TEXT($svgRef;$imageRef)
> 
> PICTURE PROPERTIES($gPicture;$lWidth;$lHeight)
> $svgRef:=SVG_New ($lWidth;$lHeight)
> $imageRef:=SVG_New_embedded_image ($svgRef;$gPicture;0;0;".jpeg")
> 
> If (($rDegrees=90) | ($rDegrees=270))
>   SVG_SET_TRANSFORM_ROTATE ($imageRef;$rDegrees;($lHeight/2);($lWidth/2))
>   SVG_SET_TRANSFORM_TRANSLATE 
> ($imageRef;(($lHeight-$lWidth)/2);(($lWidth-$lHeight)/2))
>   DOM SET XML 
> ATTRIBUTE($svgRef;"height";String($lWidth);"width";String($lHeight))
> Else   //180
>   SVG_SET_TRANSFORM_ROTATE ($imageRef;$rDegrees;($lWidth/2);($lHeight/2))
> End if 
> 
> $0:=SVG_Export_to_picture ($svgRef)
> SVG_CLEAR ($svgRef)
> 
> HTH.
> 
> --
> Cannon.Smith
> Synergy Farm Solutions Inc.
> Aetna, AB Canada
> 
> 
> 
> 
>> On Jun 22, 2019, at 3:34 PM, JOHN BAUGHMAN via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> If not 4D commands, what is the quickest and easiest way to rotate a picture 
>> in a picture variable? Anyone got code they could share?
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture

2019-06-22 Thread Cannon Smith via 4D_Tech
Hi John,

Here is the code from a method I use called Photo_Rotate:

  //This method rotates a picture. While it will rotate the picture to
  //any angle, this method is really expecting it to rotate 90˚, 180˚,
  //or 270˚.

C_PICTURE($1;$gPicture)
C_REAL($2;$rDegrees)  //Expects 90, 180, or 270
C_PICTURE($0)

$gPicture:=$1
$rDegrees:=$2

C_LONGINT($lWidth;$lHeight)
C_TEXT($svgRef;$imageRef)

PICTURE PROPERTIES($gPicture;$lWidth;$lHeight)
$svgRef:=SVG_New ($lWidth;$lHeight)
$imageRef:=SVG_New_embedded_image ($svgRef;$gPicture;0;0;".jpeg")

If (($rDegrees=90) | ($rDegrees=270))
SVG_SET_TRANSFORM_ROTATE ($imageRef;$rDegrees;($lHeight/2);($lWidth/2))
SVG_SET_TRANSFORM_TRANSLATE 
($imageRef;(($lHeight-$lWidth)/2);(($lWidth-$lHeight)/2))
DOM SET XML 
ATTRIBUTE($svgRef;"height";String($lWidth);"width";String($lHeight))
Else   //180
SVG_SET_TRANSFORM_ROTATE ($imageRef;$rDegrees;($lWidth/2);($lHeight/2))
End if 

$0:=SVG_Export_to_picture ($svgRef)
SVG_CLEAR ($svgRef)

HTH.

--
Cannon.Smith
Synergy Farm Solutions Inc.
Aetna, AB Canada




> On Jun 22, 2019, at 3:34 PM, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> If not 4D commands, what is the quickest and easiest way to rotate a picture 
> in a picture variable? Anyone got code they could share?

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread Keisuke Miyako via 4D_Tech
http://blog.4d.com/component-source-code-sharing-4d-partners/

good news is that svg component is open source


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread Peter Mew via 4D_Tech
V13 I'm afraid
Thanks
-pm

Sent from my iPad

> On 27 Jun 2017, at 08:52, Vincent de Lachaux via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Hello,
> 
> If you are using v14 or more, you can try the command SVG_ROTATION_CENTERED ( 
> svgObject ; angle )
> 
> 
> 
> 
> 
>> On 27 Jun 2017, at 08:53, Bernd Fröhlich via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> Peter Mew:
>> 
>>> I am trying to use Miyako's rotate picture component in v13.
>>> I dont know if its not compatible but It wont run.
>> 
>> Hi Peter,
>> I had some problems also (not sure what exactly), so I rolled my own:
>> 
>> // Methode: PIC_Rotate
>> // Angelegt: BF 04.04.12
>> // Objekt: Bildbearbeitung
>> // Beschreibung: Dreht das übergebene Bild um 90,180 oder 270 Grad im 
>> Uhrzeigersinn
>> // 
>> 
>> C_PICTURE($1;$Pict)
>> C_LONGINT($2)  //Rotationsgrad
>> C_PICTURE($0)
>> 
>> C_LONGINT($lWidth;$lHeigth;$lMax)
>> C_TEXT($tSVGRoot;$tPicRef)
>> 
>> PICTURE PROPERTIES($1;$lWidth;$lHeigth)
>> CREATE THUMBNAIL($1;$Pict;$lWidth;$lHeigth)  //EXIF-Daten entfernen, sonst 
>> geht SVG_SET_TRANSFORM_ROTATE schief, wenn EXIF-Tags am Bild kleben, die 
>> auch schon Rotationsinfos enthalten!
>> $lMax:=MaxInt ($lWidth;$lHeigth)
>> $tSVGRoot:=SVG_New ($lMax*2;$lMax*2)  //Bereich der gross genug ist, Platz 
>> für das Bild und die Rotation zu haben
>> $tPicRef:=SVG_New_embedded_image ($tSVGRoot;$Pict;$lMax;$lMax)  //Obere 
>> Linke Ecke des Bildes ist jetzt am Punkt $lMax,$lMax. Um diesen Punkt wird 
>> das Bild rotiert
>> SVG_SET_TRANSFORM_ROTATE ($tPicRef;$2;$lMax;$lMax)
>> $0:=SVG_Export_to_picture ($tSVGRoot;1)
>> //Jetzt noch den gedrehten Teil wieder extrahieren:
>> Case of
>> : ($2=90)
>> TRANSFORM PICTURE($0;Crop;$lMax-$lHeigth;$lMax;$lHeigth;$lWidth)  //Breite 
>> und Höhe vertauscht, da das Bild gedreht wurde
>> : ($2=180)
>> TRANSFORM PICTURE($0;Crop;$lMax-$lWidth;$lMax-$lHeigth;$lWidth;$lHeigth)
>> : ($2=270)
>> TRANSFORM PICTURE($0;Crop;$lMax;$lMax-$lWidth;$lHeigth;$lWidth)  //Breite 
>> und Höhe vertauscht, da das Bild gedreht wurde
>> Else
>> g4D_AlertErrCaseOf (Current method name;String($2))
>> End case
>> SVG_CLEAR ($tSVGRoot)
>> 
>> 
>> Works, but unfortunately is quite slow.
>> I wonder when 4D will implement a native picture rotate method.
>> I think it is much needed.
>> 
>> Greetings from Germany,
>> Bernd Fröhlich
>> **
>> 4D Internet Users Group (4D iNUG)
>> FAQ:  http://lists.4d.com/faqnug.html
>> Archive:  http://lists.4d.com/archives.html
>> Options: http://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
>> **
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread Peter Mew via 4D_Tech
Hi Bernd
I went with LEP and imagemagick, which is also quite slow.
I will try your code and see how it compares"
Thanks
-pm

Sent from my iPad

> On 27 Jun 2017, at 07:53, Bernd Fröhlich via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Peter Mew:
> 
>> I am trying to use Miyako's rotate picture component in v13.
>> I dont know if its not compatible but It wont run.
> 
> Hi Peter,
> I had some problems also (not sure what exactly), so I rolled my own:
> 
>  // Methode: PIC_Rotate
>  // Angelegt: BF 04.04.12
>  // Objekt: Bildbearbeitung
>  // Beschreibung: Dreht das übergebene Bild um 90,180 oder 270 Grad im 
> Uhrzeigersinn
>  // 
> 
> C_PICTURE($1;$Pict)
> C_LONGINT($2)  //Rotationsgrad
> C_PICTURE($0)
> 
> C_LONGINT($lWidth;$lHeigth;$lMax)
> C_TEXT($tSVGRoot;$tPicRef)
> 
> PICTURE PROPERTIES($1;$lWidth;$lHeigth)
> CREATE THUMBNAIL($1;$Pict;$lWidth;$lHeigth)  //EXIF-Daten entfernen, sonst 
> geht SVG_SET_TRANSFORM_ROTATE schief, wenn EXIF-Tags am Bild kleben, die auch 
> schon Rotationsinfos enthalten!
> $lMax:=MaxInt ($lWidth;$lHeigth)
> $tSVGRoot:=SVG_New ($lMax*2;$lMax*2)  //Bereich der gross genug ist, Platz 
> für das Bild und die Rotation zu haben
> $tPicRef:=SVG_New_embedded_image ($tSVGRoot;$Pict;$lMax;$lMax)  //Obere Linke 
> Ecke des Bildes ist jetzt am Punkt $lMax,$lMax. Um diesen Punkt wird das Bild 
> rotiert
> SVG_SET_TRANSFORM_ROTATE ($tPicRef;$2;$lMax;$lMax)
> $0:=SVG_Export_to_picture ($tSVGRoot;1)
>  //Jetzt noch den gedrehten Teil wieder extrahieren:
> Case of 
>: ($2=90)
>TRANSFORM PICTURE($0;Crop;$lMax-$lHeigth;$lMax;$lHeigth;$lWidth)  
> //Breite und Höhe vertauscht, da das Bild gedreht wurde
>: ($2=180)
>TRANSFORM 
> PICTURE($0;Crop;$lMax-$lWidth;$lMax-$lHeigth;$lWidth;$lHeigth)
>: ($2=270)
>TRANSFORM PICTURE($0;Crop;$lMax;$lMax-$lWidth;$lHeigth;$lWidth)  
> //Breite und Höhe vertauscht, da das Bild gedreht wurde
>Else 
>g4D_AlertErrCaseOf (Current method name;String($2))
> End case 
> SVG_CLEAR ($tSVGRoot)
> 
> 
> Works, but unfortunately is quite slow.
> I wonder when 4D will implement a native picture rotate method.
> I think it is much needed.
> 
> Greetings from Germany,
> Bernd Fröhlich
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread Keisuke Miyako via 4D_Tech
by the way,

GD has a rotate function too,

https://github.com/miyako/4d-plugin-gd

also available via 4D native PHP


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread Vincent de Lachaux via 4D_Tech
Hello,

If you are using v14 or more, you can try the command SVG_ROTATION_CENTERED ( 
svgObject ; angle )





> On 27 Jun 2017, at 08:53, Bernd Fröhlich via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
>
> Peter Mew:
>
>> I am trying to use Miyako's rotate picture component in v13.
>> I dont know if its not compatible but It wont run.
>
> Hi Peter,
> I had some problems also (not sure what exactly), so I rolled my own:
>
>  // Methode: PIC_Rotate
>  // Angelegt: BF 04.04.12
>  // Objekt: Bildbearbeitung
>  // Beschreibung: Dreht das übergebene Bild um 90,180 oder 270 Grad im 
> Uhrzeigersinn
>  // 
>
> C_PICTURE($1;$Pict)
> C_LONGINT($2)  //Rotationsgrad
> C_PICTURE($0)
>
> C_LONGINT($lWidth;$lHeigth;$lMax)
> C_TEXT($tSVGRoot;$tPicRef)
>
> PICTURE PROPERTIES($1;$lWidth;$lHeigth)
> CREATE THUMBNAIL($1;$Pict;$lWidth;$lHeigth)  //EXIF-Daten entfernen, sonst 
> geht SVG_SET_TRANSFORM_ROTATE schief, wenn EXIF-Tags am Bild kleben, die auch 
> schon Rotationsinfos enthalten!
> $lMax:=MaxInt ($lWidth;$lHeigth)
> $tSVGRoot:=SVG_New ($lMax*2;$lMax*2)  //Bereich der gross genug ist, Platz 
> für das Bild und die Rotation zu haben
> $tPicRef:=SVG_New_embedded_image ($tSVGRoot;$Pict;$lMax;$lMax)  //Obere Linke 
> Ecke des Bildes ist jetzt am Punkt $lMax,$lMax. Um diesen Punkt wird das Bild 
> rotiert
> SVG_SET_TRANSFORM_ROTATE ($tPicRef;$2;$lMax;$lMax)
> $0:=SVG_Export_to_picture ($tSVGRoot;1)
>  //Jetzt noch den gedrehten Teil wieder extrahieren:
> Case of
> : ($2=90)
> TRANSFORM PICTURE($0;Crop;$lMax-$lHeigth;$lMax;$lHeigth;$lWidth)  //Breite 
> und Höhe vertauscht, da das Bild gedreht wurde
> : ($2=180)
> TRANSFORM PICTURE($0;Crop;$lMax-$lWidth;$lMax-$lHeigth;$lWidth;$lHeigth)
> : ($2=270)
> TRANSFORM PICTURE($0;Crop;$lMax;$lMax-$lWidth;$lHeigth;$lWidth)  //Breite und 
> Höhe vertauscht, da das Bild gedreht wurde
> Else
> g4D_AlertErrCaseOf (Current method name;String($2))
> End case
> SVG_CLEAR ($tSVGRoot)
>
>
> Works, but unfortunately is quite slow.
> I wonder when 4D will implement a native picture rotate method.
> I think it is much needed.
>
> Greetings from Germany,
> Bernd Fröhlich
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread bernard--- via 4D_Tech

> Le 27 juin 2017 à 08:53, Bernd Fröhlich via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> Peter Mew:
> 
>> I am trying to use Miyako's rotate picture component in v13.
>> I dont know if its not compatible but It wont run.
> 
> Hi Peter,
> I had some problems also (not sure what exactly), so I rolled my own:
> 
>  // Methode: PIC_Rotate
> ...
> 
> Works, but unfortunately is quite slow.
> I wonder when 4D will implement a native picture rotate method.
> I think it is much needed.
> 
> Greetings from Germany,
> Bernd Fröhlich

It would be useful to have a lossless rotation method for multiples of 90° !

Cordialement,

Bernard Escaich

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-27 Thread Bernd Fröhlich via 4D_Tech
Peter Mew:

> I am trying to use Miyako's rotate picture component in v13.
> I dont know if its not compatible but It wont run.

Hi Peter,
I had some problems also (not sure what exactly), so I rolled my own:

  // Methode: PIC_Rotate
  // Angelegt: BF 04.04.12
  // Objekt: Bildbearbeitung
  // Beschreibung: Dreht das übergebene Bild um 90,180 oder 270 Grad im 
Uhrzeigersinn
  // 

C_PICTURE($1;$Pict)
C_LONGINT($2)  //Rotationsgrad
C_PICTURE($0)

C_LONGINT($lWidth;$lHeigth;$lMax)
C_TEXT($tSVGRoot;$tPicRef)

PICTURE PROPERTIES($1;$lWidth;$lHeigth)
CREATE THUMBNAIL($1;$Pict;$lWidth;$lHeigth)  //EXIF-Daten entfernen, sonst geht 
SVG_SET_TRANSFORM_ROTATE schief, wenn EXIF-Tags am Bild kleben, die auch schon 
Rotationsinfos enthalten!
$lMax:=MaxInt ($lWidth;$lHeigth)
$tSVGRoot:=SVG_New ($lMax*2;$lMax*2)  //Bereich der gross genug ist, Platz für 
das Bild und die Rotation zu haben
$tPicRef:=SVG_New_embedded_image ($tSVGRoot;$Pict;$lMax;$lMax)  //Obere Linke 
Ecke des Bildes ist jetzt am Punkt $lMax,$lMax. Um diesen Punkt wird das Bild 
rotiert
SVG_SET_TRANSFORM_ROTATE ($tPicRef;$2;$lMax;$lMax)
$0:=SVG_Export_to_picture ($tSVGRoot;1)
  //Jetzt noch den gedrehten Teil wieder extrahieren:
Case of 
: ($2=90)
TRANSFORM 
PICTURE($0;Crop;$lMax-$lHeigth;$lMax;$lHeigth;$lWidth)  //Breite und Höhe 
vertauscht, da das Bild gedreht wurde
: ($2=180)
TRANSFORM 
PICTURE($0;Crop;$lMax-$lWidth;$lMax-$lHeigth;$lWidth;$lHeigth)
: ($2=270)
TRANSFORM PICTURE($0;Crop;$lMax;$lMax-$lWidth;$lHeigth;$lWidth) 
 //Breite und Höhe vertauscht, da das Bild gedreht wurde
Else 
g4D_AlertErrCaseOf (Current method name;String($2))
End case 
SVG_CLEAR ($tSVGRoot)


Works, but unfortunately is quite slow.
I wonder when 4D will implement a native picture rotate method.
I think it is much needed.

Greetings from Germany,
Bernd Fröhlich
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-25 Thread Keisuke Miyako via 4D_Tech
it's not so much "my" component since rotating a picture is an innate feature 
of SVG.
the only the component does it is make sure the center of rotation is at the 
center of the image.

did you look into the source of the resulting SVG?
the center of rotation is probably wrong.

https://github.com/miyako/4d-component-rotate-picture

> 2017/06/26 4:51、Peter Mew via 4D_Tech <4d_tech@lists.4d.com> のメール:
> I am trying to use Miyako's rotate picture component in v13.




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-25 Thread Peter Mew via 4D_Tech
Yes
Same Result
Thanks
-pm

On Sun, Jun 25, 2017 at 9:49 PM, Spencer Hinsdale 
wrote:

>
> did you try 270?
>
> > On Jun 25, 2017, at 12:51 PM, Peter Mew via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >
> > Hi
> > I am trying to use Miyako's rotate picture component in v13.
> > I dont know if its not compatible but It wont run.
> > So Ive extracted the code and made it a subroutine (Rotate_Picture)
> >
> > C_PICTURE($1;$0)
> > C_REAL($2;$w;$h;$ww;$hh;$s;$c)
> >
> > PICTURE PROPERTIES($1;$w;$h)
> >
> > $s:=Sin($2*Degree)
> > $c:=Cos($2*Degree)
> >
> > $ww:=($w*$c)+($h*$s)
> > $hh:=($w*$s)+($h*$c)
> >
> > $svg:=SVG_New ($ww;$hh)
> > $g:=SVG_New_group ($svg)
> > $image:=SVG_New_embedded_image ($g;$1;($ww/2)-($w/2);($hh/2)-($h/2))
> > SVG_SET_TRANSFORM_ROTATE ($g;$2;$ww/2;$hh/2)
> >
> > $0:=SVG_Export_to_picture ($svg)
> > SVG_CLEAR ($svg)
> >
> >
> > I then Call
> > New_Picture:=Rotate_Picture(Old_Picture;degrees)
> >
> > If I call this routine with 90 as the rotation degrees it works, if I try
> > with -90 degrees it doesnt. Can anyone see why and suggest a modification
> > to make it so
> > thanks
> > -pm
> > **
> > 4D Internet Users Group (4D iNUG)
> > FAQ:  http://lists.4d.com/faqnug.html
> > Archive:  http://lists.4d.com/archives.html
> > Options: http://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> > **
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Rotate Picture in 4D

2017-06-25 Thread Spencer Hinsdale via 4D_Tech

did you try 270?

> On Jun 25, 2017, at 12:51 PM, Peter Mew via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Hi
> I am trying to use Miyako's rotate picture component in v13.
> I dont know if its not compatible but It wont run.
> So Ive extracted the code and made it a subroutine (Rotate_Picture)
> 
> C_PICTURE($1;$0)
> C_REAL($2;$w;$h;$ww;$hh;$s;$c)
> 
> PICTURE PROPERTIES($1;$w;$h)
> 
> $s:=Sin($2*Degree)
> $c:=Cos($2*Degree)
> 
> $ww:=($w*$c)+($h*$s)
> $hh:=($w*$s)+($h*$c)
> 
> $svg:=SVG_New ($ww;$hh)
> $g:=SVG_New_group ($svg)
> $image:=SVG_New_embedded_image ($g;$1;($ww/2)-($w/2);($hh/2)-($h/2))
> SVG_SET_TRANSFORM_ROTATE ($g;$2;$ww/2;$hh/2)
> 
> $0:=SVG_Export_to_picture ($svg)
> SVG_CLEAR ($svg)
> 
> 
> I then Call
> New_Picture:=Rotate_Picture(Old_Picture;degrees)
> 
> If I call this routine with 90 as the rotation degrees it works, if I try
> with -90 degrees it doesnt. Can anyone see why and suggest a modification
> to make it so
> thanks
> -pm
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**