Hi,
I'm using php 4.4.4. Maybe I'm misreading the docs, but in the
imagettfbbox manual ( http://us2.php.net/imagettfbbox), it says that
text coordinates are the same regardless of what the angle is. But I
am getting two distinct sets of coordinates if I change the angle from
zero to 270.
Here's the relevant code:
$text = "hello";
$s = getImageSize($i mg_file);
$imgWidth = $s[0];
$imgHeight = $s[1];
$source=ImageCr eateFromJPEG($i mg_file);
$size=16;
$black=imagecol orallocate($sou rce,0,0,0);
$font='/usr/share/fonts/msttcorefonts/times.ttf';
$bbox=imagettfb box($size,$angl e,$font,$text);
$textWidth=$bbo x[2]-$bbox[0];
$textHeight=$bb ox[5]-$bbox[3];
$x=($imgWidth/2)-($textWidth/2);
$y=($imgHeight/2)-($textHeight/2);
imagettftext($s ource,$size,$an gle,$x,$y,$blac k,$font,$text );
header("Content-type: image/jpeg");
When I print out the bbox with 0, I get
Array ( [0] =-3 [1] =-1 [2] =41 [3] =-1 [4] =41 [5] =-16
[6] =-3 [7] =-16 )
with 270, I get
Array ( [0] =-13 [1] =-1 [2] =-13 [3] =41 [4] =-1 [5] =41
[6] =-1 [7] =-1 )
I must be misinterpreting the docs. Why are the coordinates
different? - Dave 2 2554
On Thu, 13 Mar 2008 18:18:13 +0100, la***********@z ipmail.com
<la***********@ zipmail.comwrot e:
I'm using php 4.4.4. Maybe I'm misreading the docs, but in the
imagettfbbox manual (http://us2.php.net/imagettfbbox), it says that
text coordinates are the same regardless of what the angle is.
Nope
But I
am getting two distinct sets of coordinates if I change the angle from
zero to 270.
Here's the relevant code:
$text = "hello";
$s = getImageSize($i mg_file);
$imgWidth = $s[0];
$imgHeight = $s[1];
$source=ImageCr eateFromJPEG($i mg_file);
$size=16;
$black=imagecol orallocate($sou rce,0,0,0);
$font='/usr/share/fonts/msttcorefonts/times.ttf';
$bbox=imagettfb box($size,$angl e,$font,$text);
$textWidth=$bbo x[2]-$bbox[0];
$textHeight=$bb ox[5]-$bbox[3];
$x=($imgWidth/2)-($textWidth/2);
$y=($imgHeight/2)-($textHeight/2);
imagettftext($s ource,$size,$an gle,$x,$y,$blac k,$font,$text );
header("Content-type: image/jpeg");
When I print out the bbox with 0, I get
Array ( [0] =-3 [1] =-1 [2] =41 [3] =-1 [4] =41 [5] =-16
[6] =-3 [7] =-16 )
with 270, I get
Array ( [0] =-13 [1] =-1 [2] =-13 [3] =41 [4] =-1 [5] =41
[6] =-1 [7] =-1 )
I must be misinterpreting the docs. Why are the coordinates
different? - Dave
"The points are relative to the text regardless of the angle , so "upper
left" means in the top left-hand corner seeing the text horizontally."
Which means that with normal text without an angle, you have this box with
the array-indexes:
6,7---------4,5
| |
0,1---------2,3
However, if you have an angle of 180 (text upside down), you see this
picture:
2,3---------0,1
| |
4,5---------6,7
So, 0 & 1 hold the 'lower left corner IF you see the text horizontally' as
opposed to the 'lower left corner if you look at the picture'. The
coordinates WILL change if the angele changes (how could they not?), but
the different indexes will be for the same relative position from the text
if you were to look at the image the way the text appears horizontal
again. (Damned, this is far more easily explained face-to-face by just
rotating a piece of paper...).
--
Rik Wasmus
Greetings, Rik Wasmus.
In reply to Your message dated Thursday, March 13, 2008, 21:31:59,
(Damned, this is far more easily explained face-to-face by just
rotating a piece of paper...).
QFT :D
Thanks BTW, I was about to use this function myself and You just saved me time
to uncover this info by my own trials and errors.
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gerrit Holl |
last post by:
Hi,
the FAQ says:
> For example, a Cartesian coordinate is appropriately represented as a
> tuple of two or three numbers.
I find it strange to use tuples for a coordinate. After all, a
coordinate represents a position of an object. Suppose I have a game
where the player has a position: isn't it stupid to use tuples rather
|
by: Darren Grant |
last post by:
Hi there,
I've attempted to implement an Angle class. An Angle is a subset of an
integer, where the range is [0,360). All other operations should be
permitted.
The code works, I think... except (for example) a = b + 10;
needs to be a = b + (Angle) 10;
Could some kind soul comment on my code and show me how it could be
|
by: Siegfried Heintze |
last post by:
I want to implement drag and drop for tables, divs, spans. The problem is
that I don't know how wide or long my tables, divs and spans are going to be
in advance so I cannot use absolute coordinates. (It always seemed odd to me
that there is no function called GetExtent that would return the bounding
rectangle of an object -- this would solve my problem).
There is a way, however, to fetch the coordinates of an object (such as a
table, or...
|
by: CroDude |
last post by:
I've made a custom groupbox control. Inside, as one of it's members is
CSimpleGradient object. CSimpleGradient is a wrapper class for gradient
usage. Basically it looks like that:
public class CSimpleGradient
{
private float m_GradientAngle;
private Color m_ColorA;
private Color m_ColorB;
|
by: pcnerd |
last post by:
I created a demo program with a status bar & status bar label on the form.
When the program runs, it's maximized. When I move the mouse over the form, I
can see the X & Y coordinates changing on the status bar label. Here's the
problem. I have a 19" LCD monitor with a resolution of 1280 by 1024. When the
program runs & the mouse is in the upper-left corner, the X & Y coordinates
are 0,0. When the mouse is in the lower-right corner, the X &...
| |
by: giloosh |
last post by:
how would i get the distance and angle between 2 points on the screen.
For example:
what is the distance between (100,50) and (250,70)
what i really wanna do is see how far the current mouse position is
from a given object and what the angle is between them.
Any help please?
Thanks,
Gil
|
by: jackiepatti |
last post by:
QUESTION:
I have a web page containing a form that contains an image instead of a
submit button, e.g.
<form name='myform' action='get' method='otherpage.asp'>
<input type='image' src='picture.gif' name='myimage' id='myimage'>
</form>
When forms with image types are submitted, the value is not returned;
instead, when the form is submitted, the XY coordinates of the where
the user clicked on the image are sent. For example, if the user
|
by: eragon |
last post by:
Im trying to put a captcha image in my site to stop people from spamming, and when i view the image its self i get this:
Fatal error: Call to undefined function imagettfbbox() in (...)/htdocs/CaptchaSecurityImages.php on line 39
so heres my code:
<?php
session_start();
|
by: mingke |
last post by:
Hi....
I'm having difficulties with my codes to list coordinates (in my example codes is 4x4 pixel). I tried two different codes and the results are different.Basically, I tried to declare the sub coordinates for x and y, and then print it. But, if I make a change by declaring sub coordinates for x and print it, and the declare sub coordinate for y and print it, the results are different.
I have tried to calculated manually, the right...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |