xna 16bit texture looks like 8bit - silverlight

I have a 16bit texture that is displayed on a model in an xna+silverlight app.
Here is the texture
But, it is rendered like this:
I tried loading png instead of jpg, loading from stream and some other stuff I forgot, but nothing seems to work.
Update:
I tried setting PreferredBackBufferFormat to SurfaceFormat.Color, nothing changed.
Update2:
Xna is displaying in 16bit by default. 5 bit for R, 6G and 5 B. After converting my texture to 565 it looks exactly like the one rendered.
There probably is no solution that would satisfy me, so I'm will be trying some other approach.

On Windows Phone 7, is you want to use 32 bits colors, you have to explicitely activate it in the application manifest.
Open the WMAppManifest.xml file, search the App node, and add the attribute BitsPerPixel="32"
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769509(v=vs.105).aspx

Related

convert pdf with 300dpi bitmaps to svg

I'm creating a tool to convert pdf's into svg. These pdf's contain graphical data, including large bitmaps at 300 dpi and a bunch of vectors as well. Poking around here on stackoverflow, I've found pdf2svg, which great -- works like a charm, and the vector data is perfect. But it looks like the bitmaps are getting downscaled to 72dpi. The dimensions are still 8x10 in inches, but you can tell that the dpi isn't right when you zoom in. Soft of makes sense that the default values would presume 72 dpi, but I need the full resolution bitmap images.
pdf2svg uses poppler and cairo to make the conversion. I've poked around in the code, and I see where it's creating a poppler page and a cairo surface, and I've seen in the documentation that a poppler page has a concept of "scale" that seems relevant, but I can't figure out where to plug it in. I tried (experimentally) hardcoding the height and width passed into cairo_svg_surface_create to the correct values, but it made the dimensions applied to the whole svg larger, without affecting the embedded bitmap.
poppler_page_get_size (page, &width, &height);
// Open the SVG file
surface = cairo_svg_surface_create(svgFilename, width, height);
drawcontext = cairo_create(surface);
// Render the PDF file into the SVG file
poppler_page_render(page, drawcontext);
cairo_show_page(drawcontext);
I don't think what I'm trying to do is very esoteric, so I'm hoping someone who has experience with the libraries will see my error right away. Any help, of course, would be immensely appreciated.
I just made the change to the source as described in http://lists.freedesktop.org/archives/poppler/2011-December/008451.html and it worked perfectly - the images seem to be at their native resolution.
Replace
poppler_page_render(page, drawcontext);
with
poppler_page_render_for_printing(page, drawcontext);
Does cairo_surface_set_fallback_resolution() perhaps help? (No, I'm not even sure about this myself)

C, GTK: display stream of RGB images at < 60 fps

I'm developing an application that shall receive images from a camera device and display them in a GTK window.
The camera delivers raw RGB images (3 bytes per pixel, no alpha channel, fixed size) at a varying frame rate (1-50 fps).
I've already done all that hardware stuff and now have a callback function that gets called with every new image captured by the camera.
What is the easyest but fast enough way to display those images in my window?
Here's what I already tried:
using gdk_draw_rgb_image() on a gtk drawing area: basically worked, but rendered so slow that the drawing processes overlapped and the application crashed after the first few frames, even at 1 fps capture rate.
allocating a GdkPixbuf for each new frame and calling gtk_image_set_from_pixbuf() on a gtk image widget: only displays the first frame, then I see no change in the window. May be a bug in my code, but don't know if that will be fast enough.
using Cairo (cairo_set_source_surface(), then cairo_paint()): seemed pretty fast, but the image looked striped, don't know if the image format is compatible.
Currently I'm thinking about trying something like gstreamer and treating those images like a video stream, but I'm not sure whether this is like an overkill for my simple mechanism.
Thanks in advance for any advice!
The entire GdkRGB API seems to be deprecated, so that's probably not the recommended way to solve this.
The same goes for the call to render a pixbuf. The documentation there points at Cairo, so the solution seems to be to continue investigating why your image looked incorrect when rendered by Cairo.
unwind is right, cairo is the way to go if you want something that will work in GTK2 and GTK3. As your samples are RGB without alpha, you should use the CAIRO_FORMAT_RGB24 format. Make sure the surface you paint is in that format. Also try to make sure that you're not constantly allocating/destroying the surface buffer if the input image keeps the same size.

Font smoothing using cairo

I am trying to smooth text rendering using anti-aliasing.
But it's not anti-aliased.
First line is a png image created using pango and cairo.
Second line is just an html <span> tag. It's in firefox, Ubuntu with Gnome DE.
The difference can be better understood if you compare "W" and "v"
between two lines.
The code responsible to draw text can be found on http://pastie.org/1073683
Font options are set on lines 17 and 20 like so:
// setting up antialiasing
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_GRAY);
// set the font options to cairo
cairo_set_font_options(this->cro, cfo);
Could anyone please tell me how can I make those two lines look the same?
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_GRAY);
You asked for it, you got it. To get a match you'd need CAIRO_ANTIALIAS_SUBPIXEL. This is however not appropriate when you draw text to an image that might be displayed on another machine. There's no guarantee that the monitor on that machine is an LCD panel with the RGB stripes in a predictable order. Or that it in landscape orientation. Or that it is displayed with the exact original size. When there's a mismatch, the text will look quite poor.

How should I use .ico files in a Winforms Application?

I'm developing a WinForms c# 3.0 application. Our designer created quite a lot of .ico files containing all the needed art. The choice of .ico was made because quite often, the same image is needed in several places in different dimensions.
Now, it seems .ico files are really annoying to use in visual studio. The only way to use those images seems to be through images list (which aren't supported by all controls).
Compared to other resources, you can't write this :
foo.Image = global::RFQHUB.RFQHUBClient.Properties.Resources.foo; // Cannot implicitly convert type 'System.Drawing.Icon' to 'System.Drawing.Image'
Here are the options I'm considering :
create ImageLists of all possible sizes referencing all my icons in my main window. Link these ImageLists from other windows and find a way to export Image objects from the ImageList when I can't use it directly ; since ImageList contains a Draw() method, this should probably be possible.
convert all the x.ico I've got in several x16.gif ...x48.gif, and use those through resources.
I'd be interested to know if some people have been successfully using .ico resources in a Winform application. In so, how did you set up things ?
ICO isn't quite an obsolete format, but it's close. It's still useful for your application icon, but for almost everything else, it's better to use an ImageList for each size that you need. And it's much faster to populate an ImageList from a bitmap that contains multiple images layed out in a grid.
You also want to use an Alpha channel transparency in your bitmaps to get the best result, so storing them as .PNG files in your resources is the best way to go, since PNG supports an alpha channel. ICO and GIF files support only single bit for transparency - every pixel is either fully opaque or fully transparent. An 8 bit alpha channel for transparency looks much nicer.
If you can send your artist back to the drawing board then you should do so, and have him/her do full anti-aliased images with alpha. If you can't, then I suggest that you write a small program to convert all of your icon files into bitmaps suitable for loading into ImageLists.
Convert the images into PNG. Point. Whoever decided to use .ico files to start with should get talked to in private - the argument holds no ground.

Get path geometry from image

If i have a logo, let's say done as a jpg or even a png. Any suggestion for how I can use that to define a path geometry? It would be really good if any suggestions could be provided for how i can do it in blend.
Thanks
Yes - I just tackled this problem for an LOB application two days ago.
I can't offer advice for Blend (though I've read that it can be done in Expression Designer). However, the best free tool I've found for this is called InkScape (http://www.inkscape.org).
It's opensource, and while it's intended primarily for editing SVG vector-based images, it has two key features that are useful to us WPFers:
It can vectorize (i.e. "trace") raster images like bitmaps and jpegs, albeit not as well as one would hope, and
It can export the vector image as XAML
You'll invariably find that you get better results from loading vector formats (like SVG, EMF, WMF, etc) and saving to XAML, than if you try to convert a bitmap/jpeg... simply because the process of vectorizing a raster image is error prone at best. So if you want to bring a company logo into XAML, try to get hold of the source files used to create the logo (perhaps done in Illustrator?) and import that into InkScape.
If this post is helpful, please be kind and give it a one-up.
Jasema is a terrific tool right for the job.
Also, don't be shy to use Blend - it is somewhat more difficult to use (drawing shapes using pen) but it gets easier pretty fast. Switch on gridlines and optionally snap to them for good results.
What both Jasema and Blend are lacking, is the ability to easily create shapes with a central symmetry (like stars), so I took parts from Jasema and created my own tool (named Radius) that works a bit like a combination of a ruler and compass.
I have a good idea but you're png, bmp, jpg or other non vector file is must be very simple because we need best scan results and only use inkscape.
Step: Drag and drop your file workspace on Inkscape, download free.
Tip: If your image is color white, Top menu item File->Document Properties-> heck Checkerboard Background and if you want uncheck Page border show.
Step: Top menu item Path-> Trace Bitmap-> Mode check what you want property, i usually use color property and if your file is png check Remove Background then click OK, then wait again Ok button is Enable and close window.
Step: Now you have a two layer, top layer vektor file and bottom layer your file. Select vector file and top menu item Edit-> XML Editor-> select svg path and look side column, d name propery in your data path value.
But this method may not always work or may not give the desired results and draw your own shapes with the scape so you can get the path data from the XML editor.
Example, my first tests this like:
and after working on it some more:
I've solved my problem (export an image as XAML) using Microsoft Expression Design 4 (Free Version). I've downloaded from the link
http://www.microsoft.com/en-us/download/confirmation.aspx?id=36180
As input, I had Adobe Ilustrator files.
Adobe Illustrator / CorelDraw is perhaps the best tool out there for these operations that I have used.
Personally, I prefer illustrator for on-screen media. These tracings can be exported into several formats such as EPS, SVG, AI, or even XAML (with this plugin)
Best of Luck !!!!
I have recently been struggling with this myself. I had a set of icons done in data and needed to update them to look nicer.
I tried everything, manually typing them out. drawing in svg, converting svg to xaml.
in the end i found a list of open source icons from google material icons.
I then used this to convert from the svg files to data
https://github.com/BerndK/SvgToXaml
It works well but not for the icons i drew myself.
I decided to place all the icons data i convert into an app i built myself that will give you the data and a preview of the icon. feel free to use and contribute. I will keep updating as much as i can.
https://github.com/sgreaves1/XamlIcons
Convert your image from png to svg in online converter, then drop file into this site http://inloop.github.io/svg2android/ and you will see pathData of your image like below shown in my image.

Resources