Anonymous avatar Anonymous committed cd53f7e

rendering works, changed background color

Comments (0)

Files changed (4)

English.lproj/MyPDFDocWin.xib

 									<reference key="NSSuperview" ref="214858758"/>
 									<reference key="NSNextKeyView" ref="899448811"/>
 									<reference key="NSDocView" ref="899448811"/>
-									<object class="NSColor" key="NSBGColor" id="853711789">
-										<int key="NSColorSpace">6</int>
-										<string key="NSCatalogName">System</string>
-										<string key="NSColorName">controlColor</string>
-										<object class="NSColor" key="NSColor">
-											<int key="NSColorSpace">3</int>
-											<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
-										</object>
+									<object class="NSColor" key="NSBGColor">
+										<int key="NSColorSpace">2</int>
+										<bytes key="NSRGB">MC43NDUwOTgwNTQ0IDAuNzQ1MDk4MDU0NCAwLjc0NTA5ODA1NDQAA</bytes>
 									</object>
 									<int key="NScvFlags">4</int>
 								</object>
 								<string key="NSContents">Go to page (a to b):</string>
 								<reference key="NSSupport" ref="26"/>
 								<reference key="NSControlView" ref="886609703"/>
-								<reference key="NSBackgroundColor" ref="853711789"/>
+								<object class="NSColor" key="NSBackgroundColor" id="853711789">
+									<int key="NSColorSpace">6</int>
+									<string key="NSCatalogName">System</string>
+									<string key="NSColorName">controlColor</string>
+									<object class="NSColor" key="NSColor">
+										<int key="NSColorSpace">3</int>
+										<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+									</object>
+								</object>
 								<object class="NSColor" key="NSTextColor" id="343509090">
 									<int key="NSColorSpace">6</int>
 									<string key="NSCatalogName">System</string>
 void beginRendering(void* data);
 
 void endRendering(void* data, bool canceled);
+
+void cp_1_pixel(const char * src, char * dst, int i, int j, int width, int height);
     //printf("end rendering");
 }
 
+/**
+ * copy 1 pixel from src to dst and flip y coordinate
+ */
+void cp_1_pixel(const char * src, char * dst, int i, int j, int width, int height) {
+    int src_idx = (i * width + j) * 4;
+    int dst_idx = ((height - i - 1) * width + j) * 4;
+    dst[dst_idx] = src[src_idx + 2];
+    dst[dst_idx + 1] = src[src_idx + 1];
+    dst[dst_idx + 2] = src[src_idx];
+    dst[dst_idx + 3] = src[src_idx + 3];
+}
+
 @implementation TronPDFView
 
 @synthesize tronPDFView = _tronPDFView;
      */
 }
 
+#pragma mark draw view
+
+-(BOOL)isFlipped {
+    return YES;
+}
+
 - (void)drawRect:(NSRect)dirtyRect {
     /*
     [[NSColor redColor] set];
             int width = _tronPDFView->GetBufferWidth();
             int height = _tronPDFView->GetBufferHeight();
             char * rgba = (char *) malloc(width * height * 4);
+            /*
             for (int i = 0; i < width * height; ++i) {
                 rgba[4*i] = bgra[4*i + 2];
                 rgba[4*i + 1] = bgra[4*i + 1];
                 rgba[4*i + 2] = bgra[4*i];
                 rgba[4*i + 3] = bgra[4*i + 3];
+            }*/
+            
+            for (int i = 0; i < height; ++i) {
+                for (int j = 0; j < width; ++j) {
+                    cp_1_pixel(bgra, rgba, i, j, width, height);
+                }
             }
+            
             CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
             CGContextRef bitmapContext = CGBitmapContextCreate(rgba,
                                                                width,
 
 }
 
-/*
--(BOOL)isFlipped {
-    return YES;
-}
-*/
-
-- (BOOL)acceptsFirstResponder 
-{
-    return YES;
-}
 
 - (void)dealloc {
     if (_tronPDFView) {
     }
 }
 
+#pragma mark event handling
+- (BOOL)acceptsFirstResponder 
+{
+    return YES;
+}
+
+- (void)mouseDown:(NSEvent*)theEvent {
+    NSLog(@"mouseDown");
+}
+
+- (void)mouseDragged:(NSEvent*)theEvent {
+    NSLog(@"mouseDragged");
+}
+
+- (void)mouseUp:(NSEvent*)theEvent {
+    NSLog(@"mouseUp");
+}
+
+- (void)mouseMoved:(NSEvent*)theEvent {
+    NSLog(@"mouseMoved"); 
+}
+
+- (void)mouseEntered:(NSEvent*)theEvent {
+    NSLog(@"mouseEntered"); 
+}
+
+- (void)mouseExited:(NSEvent*)theEvent {
+    NSLog(@"mouseExited");
+}
+
+- (void)keyDown:(NSEvent*)theEvent {
+    NSLog(@"keyDown");
+}
+
+- (void)keyUp:(NSEvent*)theEvent {
+    NSLog(@"keyUp");
+}
+
 @end

cocoapdf.xcodeproj/quincy.mode1v3

 						<key>_historyCapacity</key>
 						<integer>0</integer>
 						<key>bookmark</key>
-						<string>24A9C833120D555300A86D24</string>
+						<string>24A9C8BA120D688D00A86D24</string>
 						<key>history</key>
 						<array>
 							<string>247266D51207A845001BF4F9</string>
 							<string>24A9C78B120D343400A86D24</string>
 							<string>24A9C803120D529100A86D24</string>
 							<string>24A9C805120D529100A86D24</string>
-							<string>24A9C82C120D552B00A86D24</string>
-							<string>24A9C82D120D552B00A86D24</string>
+							<string>24A9C85D120D595200A86D24</string>
+							<string>24A9C868120D5B1A00A86D24</string>
+							<string>24A9C8AF120D65F100A86D24</string>
+							<string>24A9C8B0120D65F100A86D24</string>
 						</array>
 					</dict>
 					<key>SplitCount</key>
 										<key>_historyCapacity</key>
 										<integer>0</integer>
 										<key>bookmark</key>
-										<string>24A9C832120D555300A86D24</string>
+										<string>24A9C8B9120D688D00A86D24</string>
 										<key>history</key>
 										<array>
 											<string>241D2A8211FBCBED0067260B</string>
 	<integer>5</integer>
 	<key>WindowOrderList</key>
 	<array>
-		<string>24A9C834120D555300A86D24</string>
+		<string>24A9C8BB120D688D00A86D24</string>
 		<string>24A9C71A120D0E1200A86D24</string>
 		<string>24A9C71B120D0E1200A86D24</string>
-		<string>1CD10A99069EF8BA00B06720</string>
 		<string>/Users/quincy/Repositories/CocoaPDF/cocoapdf.xcodeproj</string>
 		<string>2492503F11CB2A5D0076F523</string>
+		<string>24E4BEA112079F7600CA10EA</string>
+		<string>1CD10A99069EF8BA00B06720</string>
 		<string>1C78EAAD065D492600B07095</string>
-		<string>24E4BEA112079F7600CA10EA</string>
 	</array>
 	<key>WindowString</key>
 	<string>190 177 788 504 0 0 1280 778 </string>
 			<key>WindowToolGUID</key>
 			<string>1CD10A99069EF8BA00B06720</string>
 			<key>WindowToolIsVisible</key>
-			<false/>
+			<true/>
 		</dict>
 		<dict>
 			<key>Identifier</key>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.