How to import a pdf file as background to GtkDrawingArea - c

I need to import a pdf file as background that I can draw on it. I want to some new figures and I want to highlighten some areas.
I was searching the Internet for the last three days. The only thing I found ist the opposite, writing to pdf files.
/* does the other way */
cairo_pdf_surface_create();
First I tried this command but when I realized that it's overwriting my source file instead of importing it.
I am using GTK3 and C for writing my program.

As you've already figured out, it's not a straightforward task: GTK doesn't have PDF rendering features, so you have to use some external library.
I recommend taking a look at Evince, GTK document viewer. It has different backends for different document types. For PDF it's ev-poppler.cc and it uses poppler library.
Inside that ev-poppler.cc there is pdf_page_render which renders a single page and pdf_document_get_page which gets a single page from backend.

Related

Windows 10 / 8 start menu tile icon size for classic WPF desktop applications

I'm actually wondering how you can control the icon size (or generally: which icon to use?) for a 'classic' WPF application appearing in the Windows 10 start menu as a tile shortcut.
I only found very few posts like this one on SO, but the only answer one gets is that the corresponding mechanisms are only implemented for 'modern' Windows apps. This may be true in terms of live tiles and manifest-based definitions.
However, there has to be a way of triggering 'bigger' icons. Specific example: I have built an WPF application that, when pinned to the start menu, only shows up with a small icon in it. This is the case for all 'classic' applications - see attached image of a shortcut to the 'Orca.exe' db editor. I do believe in a way to achieve bigger icons because I noticed the Mozilla Thunderbird application (which is a 'classical' application) shows up with this one (custom background color and big icon size).
Is there anyone who understands how to achieve this and may share his knowledge? I already extracted the used icons from executables/shortcuts and compared them, but both only provide standard icon sizes up to 256px, no difference there.
Thanks!
This is actually pretty simple, but I remember having a hard time myself finding the documentation (or realizing that this is perfectly working for 'classic' applications):
Reference: MS docs - How to customize Start screen tiles for desktop apps
You can control the described behaviour and appearence of start menu tiles with a xml file called [Software].VisualElementsManifest.xml, where [Software] has to be replaced by the name of the .exe file (without extension), e.g. thunderbird.VisualElementsManifest.xml. As you already mentioned it, you can peek into the Thunderbird folder for a working example of it's content. Basically it looks like this:
<Application xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<VisualElements
ShowNameOnSquare150x150Logo='on'
Square150x150Logo='VisualElements\VisualElements_150.png'
ForegroundText="dark"
BackgroundColor="#FF0000"/>
</Application>
You can even provide additional options and assets for proper scaling, localization and accessibility by creating proper ressource files, documentation from MS has step by step instructions for this.
Note that the documentation warns about it's deprecated content. I don't know how long this work or if they are planning to completely remove this way of tile specification in the future, however it went perfectly fine on all version of W10 so far.
Note #2: If you're trying this out with an existing installation/shortcut, you have to refresh the modification timestamp of the corresponding shortcut and then unpin/pin the tile again, otherwise the shell won't notice the new definition file existance. Simplest way to do so in PS (run as admin when modifying shortcut in the system folder):
(ls "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\[ShortcutName].lnk").lastwritetime = get-date
or from CMD within the destination folder:
copy /b [ShortcutName].lnk +,,

CUDA-C importing bitmap image

Now, I have my simple project on changing the color image into white&black image using CUDA-C.
But I got a problem with importing/loading a bitmap image into program. I don't know how to import it.
So...
CUDA-C have a specific function about importing/loading bitmap image?
If yes, what is it and how to use it?
If no, how do you do with importing/loading bitmap image?
Thank you.
There's really nothing that is CUDA-specific about loading a bitmap image into an application.
If you have a preferred method for loading a bitmap image into an application, you should be able to use it with a CUDA app. You will obviously be loading the image into the host application space first. After that, if you want to transfer it to the device, you can use any of the standard methods for transferring data to the device to accomplish this.
CUDA (i.e. the runtime API) doesn't have any specific functions for importing/loading a bitmap image
-
There are many ways to load an image. If you are already using OpenGL or DirectX, then you will want to use a method associated with one of those APIs, and then use the appropriate interop API within CUDA to manipulate the object.
If you want to import a bitmap image directly into a CUDA program without using a graphics API, take a look at the CUDA samples, as a number of them do this and provide helper functions that you may want to re-use.
For example, the dct8x8 sample provides a file called BmpUtil.cpp which contains a number of useful bitmap import/handling routines, and the dct8x8 app (dct8x8.cu) shows how these may be used directly in a CUDA app.

How to copy resources from one executable to other

Ok my question is a little odd. But here we go.
I am trying to develop an executable file "wrapper" and a console program. The task of the console program is to copy Icons and Version Informations from another exe file to the wrapper file so that both the wrapper file and the exe file looks exactly same. Apart from that the exe file is appended to the wrapper file at the end. So that when the wrapper is executed it can extract and execute the appended exe file.
My question is how do I create the wrapper file so as to accomodate the Icons and Version info from other exe file ? I mean How should my resource file be ?
And next is How to copy Icons and version info. I hv searched and found a few codes and MSDN instructions but everyone of them uses FindResource, LoadResource, etc. But by following this method, I am losing the original contents of the wrapper file. The size of my file reduces from originally 67kb to 14kb and when I open up in notepad, I see lots of contents are gone ...
can anything be done by using SHGetFileInfo() ? This can be used to get HICON from the exe file. but how do I use this HICON to replace the icon resource in the wrapper file ??
The basic approach in your previous question is correct. You definitely don't want to be mucking around with SHGetFileInfo and HICONs. The type of resource shouldn't matter.
Your wrapper should start with no resources. This ensures, for example, that any icon you add will be both first and lowest numbered and thus guaranteed to be used as the app icon.
To understand what's happening with your code, use a tool that can view the resources in the resulting exe. Visual C++ Express can't do this, but the paid versions can. Alternatively, Google turns up a bunch of free utilities to do this. Here's one, I don't know if it's any good. The page also contains links to some other tools.

.NET 3.5 - Open a PDF directly from stream in native viewer

I'm working on a WinForms C# 3.0 / .NET 3.5 project involving building some canned reports. One of the requirements of the project is to export to PDF format, and currently doing so to disk is working just fine. The question was raised, however, if it's possible to export the file to a stream and open it directly in the native viewer on the client, skipping entirely writing it to disk. I know that this is somewhat possible with ASP.Net through the use of Response.Write() headers and the like, but I need to try to do this with standard WinForms/WPF, and I've exhausted my own ideas for it. Anybody have any insight on how it might be done, if it's possible at all? Or does the file have to be written to disk first, then opened separately?
I think it is important that you ask yourself what you accomplish if you bypass the file system. Writing to a the standard temporary folder is a perfectly acceptable solution. This is typically how browsers let you view media files and pdfs. I would concentrate on writing a nice cleanup function, that removes the temporary file after it has been create. Also what would be the purpose of exporting to PDF if you are not saving the file?
Under Unix / Linux you could have made a named pipe in the file system. This make sense if you have a huge media stream that you want to buffer between applications. In the PDF case you win very little.
Export to a temporary folder. It is Ok.
You will need to write the PDF to a temp directory.
The only way to display a PDF from an in-memory stream is to embed a third-party PDF viewer control

3DS file loader for opengl

this is my 1st question in the site.
I need a 3DS model loader for opengl applications. Loader should also be able to load .jpg textures. I tried to use OpenSceneGraph for this purpose but this time I have to also use the whole OpenSceneGraph data structure to render the scene. Is it possible to use OpenSceneGraph only for model loading and do the rest with standart opengl code, especially glTranslate, glRotate, etc.
Googling turned up this: lib3ds
Not sure if it can read JPEGs but that should be easy enough with libjpeg or equivalent.
OpenSceneGraph uses "plugins" to load file formats - both models and textures. There are working plugins for 3ds and for jpeg, though at least the jpeg one (I believe) isn't built in the default configuration - when creating the OpenSceneGraph makefiles (or projects on Windows), you need to specify the location of the libjpeg files in order for it to be built (as the plugin is based on that library). Once you have these two plugins, you'll have no problem reading 3ds files and jpeg textures. Another option is to use some other convertor which supports both osg (or ive) - OpenSceneGraph's native format- and 3ds. Blender comes to mind, and it's free...
As for mixing openGL calls with OpenSceneGraph - that can be tricky, but possible. One option is to derive your own class from Drawable, then override its draw implementation method, and place it anywhere you want in the graph, though manually drawing the 3ds files defeats the whole purpose of using a scene-graph...

Resources