Corona SDK: The TabBar Doesn't Load #2x Images..? - xcode

Why the tabbar doesn't load '#2x' image automatically on iPhone4 or 5?
Here is my code:
local function init()
--Create a group that contains the entire screen and tab bar
mainView = display.newGroup()
--Create a group that contains the screens beneath the tab bar
tabView = display.newGroup()
mainView:insert(tabView)
loadScreen("info-moregames")
tabBar = viewController.newTabBar{
background = "UI_INFO/tabBar.png", --tab bar background
default = {"UI_INFO/pogi_no.png","UI_INFO/noads_no.png","UI_INFO/share_no.png","UI_INFO/star_no.png","UI_INFO/restore_no.png","UI_INFO/back_no.png"},
over = {"UI_INFO/pogi_yes.png","UI_INFO/noads_yes.png","UI_INFO/share_yes.png","UI_INFO/star_yes.png","UI_INFO/restore_yes.png","UI_INFO/back_yes.png"},
tabs = {"More", "No Ads", "Share","Rate us","Restore","back"}, --names to appear under each tab icon
onRelease = showScreen --function to execute when pressed
}
mainView:insert(tabBar)
tabBar.selected()
return true
end

If you have a config.lua file like above, your images will be automaticaly scaled.
application = {
content = {
width = ***,
height = ***,
scale = "letterBox",
}
If you have a config.lua file like above, you can use different images for different resolutions. Note that, you should have two images for that. For example, you have an image temp.png which is 20x20. Then you should have another temp#2x.png which is 40x40. In this way you can get better images with better resolution. And also, 1.5 value means that if the device's screen is 1.5 times more then your desired resolution, use images with #2x ending.
application = {
content = {
width = ***,
height = ***,
scale = "letterBox",
imageSuffix = {
["#2x"] = 1.5,
}
},
}

Related

Create Images with watermark in extbase

I have a Model that stores a FileReference. And now I want to create an Image with a Watermark in the Extbase Controller. Does anybody know where I have to look for? I only found solutions with typoscript.
I choosed the TypoScript way and it worked pretty well.
Fluid:
<f:cObject typoscriptObjectPath="lib.tx_myext.watermarkedImage" data="{imageUid:'{image.uid}',copyright:'{image.copyright}')}'}"/>
TypoScript:
lib.tx_myext.watermarkedImage = IMAGE
lib.tx_myext.watermarkedImage {
file = GIFBUILDER
file {
XY = [10.w],[10.h]
format = jpg
10 = IMAGE
10 {
file {
import.field = imageUid
treatIdAsReference = 1
width = 1162
height = 580c
}
}
20 = BOX
20 {
color = #FFFFFF
opacity = 70
dimensions = [10.w]-[30.w]-10,[10.h]-20,[30.w]+20,[30.h]+20
}
30 = TEXT
30 {
text.data = field:copyright
fontSize = 15
fontColor = #000000
fontFile = path/to/my/font.ttf
offset = [10.w]-[30.w]-5,[10.h]-5
}
}
}
The result is an image with a white box and the copyright text on it at the right bottom corner.
I think the easiest way will be to use a typoscript solution. This must not be as pure typoscript, but the datastructure of the typoscript might be needed as parameter to the core functions of the GifBuilder class. TYPO3 7.6 API
The GifBuilder class is inherited from the class GraphicalFunctions which can be used also, as there are only a few additions and the main functionality is here.
The last problem are the examples in the net according this task: they are pibased and all of them end up in something like
$img = $this->cObj->IMAGE($typoScriptArray);
in modern (namespaced) notation using current API this would be:
$gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\GifBuilder::class);
$gifCreator->init();
$theImage='';
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
$gifCreator->start($fileArray, $typoScriptArray);
$theImage = $gifCreator->gifBuild();
}

How do I add an image in the QToolbar using PyQt?

I'm creating a tool bar in PyQt. How it looks now is:
(HomeButton).............................................(ExitButton)..|
I want to use the space in the middle to put in an image/logo -- with no function so it looks like:
(homebutton)......[IMAGE/LOGO_HERE]......(exitbutton)..|
I've tried to do this by adding a widget with an image but it's not showing up. My code is:
logo = QWidget()
logolabel = QLabel(p3logo)
logopixmap = QPixmap(self.LOGO)
logolabel.setPixmap(QPixmap(self.LOGO))
logolabel.setPixmap(logopixmap)
logo.resize(logopixmap.width(),logopixmap.height())
###logoAction = QAction(QIcon('logo.png'), 'Logo', self)
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
exitAction = QAction(QIcon('exit.png'), 'Exit', self)
exitAction.setShortcut('Ctrl+X')
exitAction.triggered.connect(self.exitClicked)
homeAction = QAction(QIcon('home.png'), 'Home', self)
homeAction.setShortcut('Ctrl+H')
homeAction.triggered.connect(self.homeClicked)
self.toolbar = self.addToolBar('Toolbar')
self.toolbar.addAction(homeAction)
self.toolbar.addWidget(logo)
###self.toolbar.addAction(logoAction)
self.toolbar.addWidget(spacer)
self.toolbar.addAction(exitAction)
self.toolbar.addSeparator()
I also tried to add it in as an 'icon' but it was resized to the same size as the home/exit buttons making it hardly visible.
Your code example is effectively just adding an empty widget to the toolbar, because the label has not been put inside a layout. It looks like it can be fixed by getting rid of the container widget and simply adding the label directly:
self.toolbar.addWidget(logolabel)

How to make images saved locally actually appear on my screen?

Hello!
i'm trying to have my images appearing on a label by using this code
this is to save a random image from a particular URL
def photo_1():
urls = "https://www.flickr.com/photos/flickr/galleries/72157644537473411/" # You may change this into other websites!
regex = '<img src="([^"]+)".*>'
pattern = re.compile(regex)
photofile=urllib.urlopen(urls)
raw_data=photofile.read()
download=re.findall(pattern,raw_data)
randomdownload=random.choice(download)
urllib.urlretrieve(randomdownload, "1.gif")
global done_button2
done_button2 = Button(photo_window, text = 'Click here to display your chosen image on the black screen!', width = 53, command = generate_1)
done_button2.grid(row = 5, sticky = N)
done_button.config(state='disabled')
and this is to have the saved image appearing on a label but apparently not working so well ..
def generate_1():
img = ImageTk.PhotoImage(Image.open("1.gif"))
image_area = Label(photo_window, image = img, width = 55, height = 5).grid(row=2)
global done_button3
done_button3 = Button(photo_window, text = 'Click here to save the second random image locally! ', width = 53, command = photo_2)
done_button3.grid(row = 6, sticky = N)
done_button2.config(state='disabled')
this was a part of my code and when i run this application i made,
the only thing i can see is a white rectangular shape and i would like it to be as big as a black label underneath (size of (55,5) )with the actual image appearing...
can anyone help me with this problem?
You might have thought that my English is not that great haha
but please have mercy!

Storyboard animation only displays last frame

I have to create an animation for a Windows Phone 8.1 app. I want to change the ImageSource property of my Page.Background to display an animated splash when the app launches.
I used this sample as a model: http://www.codeproject.com/Tips/823622/Images-Animation-By-Using-Story-Board-in-Windows-P
In my code, the animation lasts 8 seconds for 80 images, but the screen stays black for 8 seconds, then only displays the last frame.
private void setupStoryboard()
{
storyboard = new Storyboard();
var animation = new ObjectAnimationUsingKeyFrames();
Storyboard.SetTarget(animation, BackgroundBrush);
Storyboard.SetTargetProperty(animation, "ImageSource");
storyboard.Children.Add(animation);
for (int i = 0; i <= 80; i++)
{
var keyframe = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100 * i)), //Time Interval
Value = String.Format("ms-appx:///Assets/Animation/splash{0:D2}.png", i) //Source of images
};
animation.KeyFrames.Add(keyframe);
}
Resources.Add("Storyboard", storyboard); //Add story board to resources
}
This code is called from OnNavigatedTo, and I have a button to call storyboard.Begin();
This problem appears on simulator and device.
Update: The problem persists with a greater interval (1000ms), and smaller images (30KB jpg instead of 240KB png)
Update: Same problem with an <Image> tag
Update: Still not solved, but I managed to obtain the desired effect. I created a DispatcherTimer to manually change the image. Unfortunately, this creates a nasty flickering effect. I had to add a second identical image on top of the first, and alternate between the two: imageA loads source1, imageB loads source2, imageA loads source3, ImageB loads source4...
Mission completed, with duct tape.

Swift - cycling through background images

I'm completely new to coding and I'm trying to learn Swift. I'm trying to cycle through background images for an app. The images I have are named 1.jpg, 2.jpg, 3.jpg, 4.jpg. When I try run the simulator, the "super.viewDidLoad()" line is highlighted green with the comment, "Thread 1, Breakpoint 3.1." Here's my code:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var imageList = [UIImage]()
for i in 1...4 {
let imageName = "\(i).jpg"
var image = UIImage(named:imageName)
imageList.append(image)
}
self.myImageView.animationImages = imageList
self.myImageView.animationDuration = 4.0
self.myImageView.startAnimating()
It sounds like you've set a breakpoint there. If there's a blue pointer to the left of the line, click it to disable it. Or, use the keyboard shortcut command-Y to disable all breakpoints.

Resources