I am using this code -
HorizontalFieldManager hfm = new HorizontalFieldManager();
this.add(hfm);
Bitmap HELLO_LOGO = Bitmap.getBitmapResource("test.jpg");
BitmapField helloBmpField = new BitmapField(HELLO_LOGO);
hfm.add(helloBmpField);
I have 3 files in the img folder under res - test.jpg,icon.png,tester.gif
I also have a labelfield in the horizontal manager.
Either of them show now but not both. I have checked the size of the image that is fine too.
I have tried all 3 files one by one - it takes up some space on the screen but the image doesn't show up with any of the 3 files
Can someone please tell me what am I doing wrong
Thanks
You could add some debug output statements to this code, and check if the image is loaded.
Missing some context, I assume this code is taken from the constructor of a Screen class. If not, this could be a problem with the event-handling thread.
First check: is the filename comlete? should it be "img/test.jpg" instead of "test.jpg"?
Check the extension of the name of the image you have put in your res folder. May be the image is named as test.JPG (capital letter for extension) in the res folder but in your code you've written test.jpg (small letter for extension) or any other naming mistake like this...
Related
I have read this article by Paweł Głowacki and I have been able to display an icon for my component. The result is the following:
I can see the image in the Tool Palette and in the structure view. By the way in the designer I see the default icon:
How can I display the icon of my component in the designer as well?
I am using Delphi Tokyo 10.2 Update 2. I have followed the article I have linked to get the image shown. My component is the following:
type
TEquationSolver = class(TComponent)
//code...
end;
Basically, I have done the following:
I have created 3 bitmaps (16x16 24x24 32x32) and a png (128x128)
I have added them as resources going into Project > Resources and Images
I have called them TEquationSolver with the suffix that indicates the size. In this way they are properly displayed on the IDE.
What am I missing for the design time part? In this article I have read the following:
Our guide is: Use PNG if you want very easy backwards compatibility,
or small file (BPL) size; use bitmaps if you want fast loading. We
use bitmaps for 16, 24, and 32px icons, and PNG for the 128px icons.
In fact I have 16x16, 24x24, 32x32 bitmaps and the 128px png. Is there something else?
It seems that you have to create the files I have shown above plus the image for the Designer. The latter needs to match the name of the class that inherits from TComponent (in my case):
As you can see I have added another bitmap (it's the 32x32, I have just made a copy and changed the name) and I have used TEquationSolver as name. After a Build + Install I have the following result:
Note that I could have added only logo.bmp as resource (with the ID that matches the TComponent-derived class name) and it would have worked anyway. The problem is that the pictures won't be neat because they'll be resized and they may appear blurred, like in my case.
For this reason I think that it's good:
Put an image that will appear in the form designer
Put the 16x16, 24x24, 32x32 and 128x128 that will be used by the IDE
The difference is evident in my case. When I have only a single bitmap the quality of the image is low but when I provide the various sizes they look better.
I am using OpenWeatherMap to get the weather data for my app.With the response data openweather is sending a weather icon code and they have a specific icon for that code which is very small ,but i want a bigger icon to use in my home page.Is there any alternative to get a bigger Icon from OpenWeatherMap.
Thanks in Advance.
Check this page to get all the icons (in #1x, #2x and #3x). Download them and add them to your assets and the system will automatically get the right one for you.
The you could increase them in your UIImageView if you want since they are png, I don´t think you will decrease the quality.
// Parameters x, y, width, height
var imageView = UIImageView(frame: CGRectMake(0, 0, 100, 100));
This icon set is a lot clearer. Just change the folder from w to wn and add #2x before the .png:
https://openweathermap.org/img/wn/01d#2x.png
I was able to enlarge the png icon like this:
const weatherIcon = document.querySelector(".weather-icon");
const iconURL = "http://openweathermap.org/img/wn/";
weatherIcon.src = iconURL + response.weather[0].icon + "#2x.png";
You should be able to replace the #2x.png with also #3x.png. To me the easiest way is to break it down to separate variables and then combine them. This code is inside my displayData function. I would put this inside your function that displays your data.
P.S. coding newbie here still learning!!!
I use these icons in my UWP app:
http://www.zephyros.wetter.com/apps_und_mehr/website/api/downloads/
I need to get preview from camera and show it on Imageview..
The code is done as follows
public void onPreviewFrame(byte[] data, Camera camera){
yuvimage = new YuvImage(data, parameters.getPreviewFormat(), width, height, null);
yuvimage.compressToJpeg(new Rect(0,0,parameters.getPreviewSize().width,parameters.getPreviewSize().height), 90, outstr);
bmp = BitmapFactory.decodeByteArray(outstr.toByteArray(), 0, outstr.size());
camera.addCallbackBuffer(data);
}
This code works fine, the if bmp passed to imageview the it displays clear color image on most of the devices, but on a tablet, it shows green/pink image..
If surfaceview is used to show preview directly then it shows clear color preview on all devices..
Any suggestion is appreciated..
If the image looks sort of correct, but just has a weird color to it, then I would guess
that the problem lies with the picture format. I would start is by trying to change parameters.getPreviewFormat() to ImageFormat.NV21 and see if that fixes the problem.
I have used basically the same code before, and never had a problem. (Although you should push the rendering to a separate thread, and probably use RenderScript to convert the pictures).
I am writing an app that does live streaming. Can I make a bitmap field go full screen when clicked?
The easiest way to do it (that I could think of in 2 minutes):
Make your bitmap clickable (described here)
When the bitmap field is clicked, scale it into a new bitmap the size of the whole screen:
Bitmap scaled = new Bitmap(Display.getWidth(), Display.getHeight());
originalBitmap.scaleInto(scaled);
Create a new Screen, containing only a BitmapField (with your scaled bitmap)
Push the new Screen.
I am wondering if it is possible to add small icons, that are available as png files, during launch time to a custom font I use in my app? The code should work on iOS5 and above. This would have several use cases. For example you could add labels with icons without using an image view and a label and layouting the stuff based on the text. I know that I have read somewhere, that apple uses this technique on their own apps, but I don't know if they add the icons on launch time or already in the design process into the font.
Any help would be appreciated.
I have simulated this by using a custom view that has a string and font property as well as one or more images. Create a mapping between special char values and images. In drawrect use the uikit category on NSString that lets you draw chars or strings. When u get to your special char you skip it and draw the image. Those draw methods return the size of the string/char so you can tell how much to move as you draw.
You can see this technique used on github, look for the CreditCard ObjectiveC. It's used to draw placeholders or chars in the PlaceHolder class
I think it is not possible to add png to font in device. Font file use vector graphics to represent every glyph. You can convert font file to SVG. But PNG is not vector graphics.
I use icon font in some of my projects. I have create a project to use icon font easily. https://github.com/JohnWong/IconFont. Icon font is always used in UILabel by setting text. But I think creating a UIImage from font is more flexible. UIImage can be used in Buttons, TabBar Items, Bar Button Items and so on. This is why I create this project. The README of this project is written in Chinese. But the demo project will show everything clearly.