logo
down
shadow

How can i create imagesurface from cairo xlib's Graphics Context using cairo and x11 Api's?


How can i create imagesurface from cairo xlib's Graphics Context using cairo and x11 Api's?

By : Finvansant
Date : December 01 2020, 04:55 PM
around this issue I am still not sure that I really understand your question, but let's try:
You have a cairo X11 surface called x11_surf and want to get the contents of that into a new image surface called img_surf:
code :


Share : facebook icon twitter icon
Convert PIL Image to Cairo ImageSurface

Convert PIL Image to Cairo ImageSurface


By : user3593129
Date : March 29 2020, 07:55 AM
hop of those help? Cairo's create_for_data() is wants a writeable buffer object (a string can be used as a buffer object, but it's not writable), and it only supports 32 bits per pixel data (RGBA, or RGB followed by one unused byte). PIL, on the other hand, provides a 24bpp RGB read-only buffer object.
I suggest you tell PIL to add an alpha channel, then convert the PIL buffer to a numpy array to get a writable buffer for Cairo.
code :
im = Image.open(filename)
im.putalpha(256) # create alpha channel
arr = numpy.array(im)
height, width, channels = arr.shape
surface = cairo.ImageSurface.create_for_data(arr, cairo.FORMAT_RGB24, width, height)
Cairo, ImageSurface : Cannot get correct alpha blending

Cairo, ImageSurface : Cannot get correct alpha blending


By : InsomniaNY
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I have finally found what was wrong with cairo and the bad alpha blending. Cairo supports ARGB32 surface, but only with premultiplied alpha. That is, every component of a pixel is stored premultiplied with the alpha component.
I have not found an answer for this over the internet, and I assume premultiplied alpha is not suited for the type of operation I'm doing. I switched to PyQt4, used ARGB32 images without premultiplication, and it worked like a charm.
Cairo introspection errors in Eclipse with PyDev `TypeError: Couldn't find conversion for foreign struct 'cairo.Context'

Cairo introspection errors in Eclipse with PyDev `TypeError: Couldn't find conversion for foreign struct 'cairo.Context'


By : Shiyang Zheng US - A
Date : March 29 2020, 07:55 AM
I wish this help you In view of the lack of response I have come up with the following workaround, which uses WebKit instead of weasyprint to do the parsing, rendering and administration of the printing from html:
code :
#!/usr/bin/env python3 

import os
from gi.repository import Gtk, WebKit

testFile = 'file://' + os.path.join(os.getcwd(), 'printTestHtml.html')

class Example(Gtk.Window):

    def __init__(self):
        super(Example, self).__init__()        
        self.init_ui()

    def init_ui(self):    
        self.set_title("Print Html WebKit Test")
        self.resize(230, 150)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect("delete-event", Gtk.main_quit)

        printButton = Gtk.Button('Press Me')
        self.add(printButton)
        printButton.connect('clicked', self.on_printButton_clicked)

        self.show_all()

    def on_printButton_clicked(self, widget):
        webView = WebKit.WebView()
        webView.load_uri(testFile)
        webFrame = webView.get_main_frame()
        webFrame.print_full(Gtk.PrintOperation(),
                            Gtk.PrintOperationAction.PRINT_DIALOG)

def main():    
    app = Example()
    Gtk.main()

if __name__ == "__main__":    
    main()
Cairo.ImageSurface to Gdk.Pixbuf?

Cairo.ImageSurface to Gdk.Pixbuf?


By : Agnes Lydia A
Date : March 29 2020, 07:55 AM
wish help you to fix your issue It turns out that the code above is exactly correct... I just wasn't drawing anything to the surface. Works great!
How do I crop an ImageSurface in Cairo?

How do I crop an ImageSurface in Cairo?


By : flerris
Date : March 29 2020, 07:55 AM
I hope this helps . I'm using the Cairo bindings for C#, and I wanted to be able to crop an ImageSurface and put it into a new ImageSurface variable, which I will then use in a seperate subroutine. The question is how would I do this properly. , You almost got it. Try this:
code :
ImageSurface OutputImage = new ImageSurface (Format.Rgb24, (int)RectangleToCropTo.Width, (int)RectangleToCropTo.Height);
using (Cairo.Context cr = new Cairo.Context(OutputImage)) {
    cr.SetSource (originalImage, -RectangleToCropTo.X, -RectangleToCropTo.Y);
    cr.Paint ();
}
Related Posts Related Posts :
  • What could be causing my WhatsApp Stickers Pack not to work?
  • How Can I Reorder/Sort The Collections List in Directus?
  • Is this language generic/mighty enough to be used for a generic game AI?
  • graphite, use regular expressions to select the target, or an alternative
  • subtract functions with type real in ml
  • how to filter '(' in navision 2013
  • sending sms from a mobile browser
  • NuGet behind firewall
  • Gstreamer hangs while generating timelapse from JPEGs on Raspberry pi
  • How to retrieve total view count of large number of pages combined from the GA API
  • Websites rich with exercices or explanation for SML?
  • Is there a TempData equivalent in ServiceStack?
  • scipy-0.12.0 failing to install on mountain lion using python setup.py install
  • Looking for simplest option to render Razor cshtml pages in a console application without any web server
  • Evaluating variables at a specific time in Modelica
  • When I run the Application, only "web" engine is running in GlassFish. "webservices" is not started
  • How To Set MIME Type Of Google Drive File
  • Remove Missing Values in Weka
  • Reloading a UICollectionView using reloadData method returns immediately before reloading data
  • carrot2 - can I cluster documents from a folder?
  • StreamSocket has no Close Implementation in C#
  • Rails, Foundation 4, Respond.js not working properly in IE8
  • CKEditor "overflow: scroll" on parent causes toolbar to freeze at initial position
  • Differences between components and controls in ENYO
  • Photoshop making isometric?
  • Does Intel IPP 8.0 support in-place operations?
  • What is Object dictionary in CANOpen?
  • Example of orbBasic Indexed User Variables
  • convert to ABSOLUTE in logback
  • How to conditionally download file using p:fileDownload
  • Error on pod install
  • Set HTTP GET Parameters in Finagle
  • different attack that uses sql injection
  • How can I change my xampp username not as 'root'
  • AMQP Content header payload structure
  • Apache POI formula evaluation not working for Excel IF
  • How can I trace RESTEasy's dispatch?
  • Map Freezes on iOS 7 with Google Maps SDK 1.4
  • Comparing lists, is the subset list within the first list
  • Non-ascii character highlight in Sublime Text 2
  • Installing Magit in Aquamacs
  • Receiving error - System.Net.Mail.SmtpException: 4.3.2 try again later
  • Coreaudio render callback in monotouch
  • The command 'yarn --v' also initiates 'yarn install' and installs packages automatically. Why is this happening?
  • save multiple matches in a list (grep or awk)
  • Can a number register be used in a groff request?
  • Mapping FAQ with RASA for large dataset (2000+)
  • Fragment not receiving LiveData updates after remove + add
  • FitText.js makes text bigger rather than smaller
  • ARM - Implementing stack with load/store multiple register values
  • How to check if a ChromeCast Session is already in progress
  • ngForm inside a Carousel Slide in UI Bootstrap not working
  • Clearing attributes in Tritium
  • "vagrant up" failing: Vagrant VM failed to remain in the running state
  • ftsearch returning empty docs
  • What are the advantages of setting "hive.exec.parallel" to false in Hive ?
  • Creating a root certificate in FiddlerCore
  • How to access app.config in a blueprint?
  • DB2 RECORDSET table name converted to uppercase
  • Resizing the superview according to the subviews
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org